获取字段名、类型、注释、是否为空:
SELECT
col_description ( A.attrelid, A.attnum ) AS COMMENT,
format_type ( A.atttypid, A.atttypmod ) AS TYPE,
A.attname AS NAME,
A.attnotnull AS NOTNULL
FROM
pg_class AS C,
pg_attribute AS A
WHERE
C.relname = '表名'
AND A.attrelid = C.oid
AND A.attnum > 0
原文链接:https://blog.csdn.net/cicon/article/details/51577655