查看pg数据库的表名字段详细描述信息语句

  • Post author:
  • Post category:其他


select t1.schemaname,t1.tablename,t1.tableowner,t3.attname,t3.attnum,format_type(t3.atttypid,t3.atttypmod),t5.description
from pg_tables t1
left join pg_namespace t4
on t1.schemaname=t4.nspname
left join PG_class t2
on t1.tablename=t2.relname
and t4.oid=t2.relnamespace
left join pg_attribute t3
on t2.oid=t3.attrelid
and t3.attnum>0
left join pg_description t5
on t3.attrelid=t5.objoid
and t3.attnum=t5.objsubid
where t1.schemaname='odsdata'-- and t1.tablename='f_ats_beps_batbuysum_s'
and t1.tablename not like '%_prt_%'
order by t1.tablename,t3.attnum

表以及表描述

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;



版权声明:本文为weixin_39150719原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。