查所有表
SELECT tablename FROM pg_tables WHERE tablename NOT LIKE'pg%' AND tablename NOT LIKE'sql_%' ORDER BY tablename;
查看当前表的所有字段
SELECT C.relname, A.attname AS NAME, A.attnotnull AS NOTNULL, format_type ( A.atttypid, A.atttypmod ) AS TYPE, col_description ( A.attrelid, A.attnum ) AS COMMENT FROM pg_class AS C, pg_attribute AS A WHERE C.relname = '表名' AND A.attrelid = C.oid AND A.attnum > 0
查看当前所有表的所有字段
SELECT C .relname, A.attname AS NAME, A.attnotnull AS NOTNULL, format_type ( A.atttypid, A.atttypmod ) AS TYPE, col_description ( A.attrelid, A.attnum ) AS COMMENT FROM pg_class AS C, pg_attribute AS A WHERE C.relname IN ( SELECT tablename FROM pg_tables WHERE tablename NOT LIKE'pg%' AND tablename NOT LIKE'sql_%' ORDER BY tablename ) AND A.attrelid = C.oid AND A.attnum > 0
标签:PostgreSQL,relname,数据库,tablename,attnum,查找,pg,SELECT,attrelid From: https://www.cnblogs.com/pythonClub/p/17662239.html