欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2024-03-21 10:52:28
...
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;
相关标签: psql