postgresql查询指定schema下的所有表

SELECT A.relname AS tableName,
    pgde.description AS comments 
FROM
    ( SELECT relname, relfilenode FROM pg_class WHERE relkind = 'r' and lower(relname) like '%def%' AND relnamespace = ( SELECT oid FROM pg_namespace WHERE nspname = 'public' ) )
    A LEFT JOIN pg_description pgde ON pgde.objoid = A.relfilenode 
    AND pgde.objsubid = 0 

sql包含指定表名的查询,如果全查就把and lower(relname) like '%def%'移除,仅此记录。

你可能感兴趣的:(postgresql,数据库)