postgresql 查询包含某字段的表

查询包含某字段的表都有哪些

查询SQL如下:

SELECT
    b.oid,
    b.relname,
    att.attname,
    b.relkind,
    attinhcount,
    atttypmod 
FROM
    pg_attribute att,
    pg_class b 
WHERE
    b.oid = att.attrelid 
    AND att.attname = 'user_name' --可以模糊查询 '%column_name%'
    AND attinhcount IN ( 0 ) 
    AND b.relkind IN ( 'r' ) 
ORDER BY
    b.relname,
    atttypmod;

 

posted @ 2021-10-08 08:41  BillyYang  阅读(1063)  评论(0编辑  收藏  举报