PostgreSQL获取数据库中所有table名:
SELECT tablename FROM pg_tables WHERE tablename NOT LIKE ‘pg%‘ AND tablename NOT LIKE ‘sql_%‘ ORDER BY tablename;
PostgreSQL获取数据库中所有table名及table的注解信息:
SELECT tablename, obj_description(relfilenode, ‘pg_class‘) FROM pg_tables a, pg_class b WHERE a.tablename = b.relname AND a.tablename NOT LIKE ‘pg%‘ AND a.tablename NOT LIKE ‘sql_%‘ ORDER BY a.tablename;
PostgreSQL获取指定table的所有字段信息:
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 = ‘tablename‘ AND a.attrelid = c.oid AND a.attnum>0
时间: 2024-12-28 11:45:33