美文网首页
pg导出表和字段注释

pg导出表和字段注释

作者: yayooo | 来源:发表于2020-08-27 10:39 被阅读0次
select
t1.relname as table_name,
t3.attname as field,
format_type(t3.atttypid,t3.atttypmod) as field_type,
case when t3.atttypid=1043 then '是' when t3.atttypid=1042 then '是' when t3.atttypid=25 then '是' else '否' end as is_string,
t3.attnum field_number,
t4.description field_comment,
t5.description table_comment
from pg_class t1
left join pg_user t2 on t1.relowner=t2.usesysid
left join pg_attribute t3 on t3.attrelid=t1.oid
left join pg_description t4 on t4.objsubid=t3.attnum and t4.objoid=t1.oid
left join pg_description t5 on t5.objoid=t1.oid and t5.objsubid=0
where t2.usename='cqsswj'
and t1.relname in(select tablename from pg_tables where schemaname='cqsswj' and tableowner='cqsswj') and t1.relname not in('cqdc_ggdmb','cqdc_sjdzb','cqdc_sjgxbs')
and attnum>0
order by relname, attnum

相关文章

网友评论

      本文标题:pg导出表和字段注释

      本文链接:https://www.haomeiwen.com/subject/fjoajktx.html