1、查询表名和表注释
select relname as tabname,
cast(obj_description(relfilenode,'pg_class') as varchar) as comment from pg_class c
where relname ='table_name' ;
2、查询字段名、字段类型及字段长度和字段注释
select a.attnum,a.attname,concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '\(.*\)')) as type,d.description from pg_class c, pg_attribute a , pg_type t, pg_description d
select relname as tabname,
cast(obj_description(relfilenode,'pg_class') as varchar) as comment from pg_class c
where relname ='table_name' ;
2、查询字段名、字段类型及字段长度和字段注释
select a.attnum,a.attname,concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '\(.*\)')) as type,d.description from pg_class c, pg_attribute a , pg_type t, pg_description d
where c.relname = 'table_name' and a.attnum>0 and a.attrelid = c.oid and a.atttypid = t.oid and d.objoid=a.attrelid and d.objsubid=a.attnum
注:table_name为表名
本文提供查询 PostgreSQL 数据库中表名、表注释、字段名、字段类型、字段长度及字段注释的方法。通过 SQL 查询实现对指定表的详细信息获取。
1万+

被折叠的 条评论
为什么被折叠?



