postgresql数据表和字段名的获取

pg库表名获取

select * from pg_tables where tablename=‘’

pg库列名和类型注释等获取

–获取字段名、类型、注释、是否为空:
SELECT col_description(a.attrelid,a.attnum) as comment,a.attname as name,format_type(a.atttypid,a.atttypmod) as type, a.attnotnull as notnull
FROM pg_class as c,pg_attribute as a where c.relname = ‘table_name’ and a.attrelid = c.oid and col_description(a.attrelid,a.attnum) is not null;

猜你喜欢

转载自blog.csdn.net/hbn1326317071/article/details/83818512