postgres数据库获取表的信息与字段的信息

来源:互联网 发布:阿里云8080绑定域名 编辑:程序博客网 时间:2024/05/20 08:45

1、获取postgres中定义表的名称与注释

select relname as TABLE_NAME ,col_description(c.oid, 0) as COMMENTS from pg_class c where  relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%'

2、获取postgres中某个表中字段的定义信息

SELECT col_description(a.attrelid,a.attnum) as comment,a.attname as name  FROM pg_class as c,pg_attribute as a where c.relname = '表名' and a.attrelid = c.oid and a.attnum>0


原创粉丝点击