select
c.relname AS "表名",
cast(obj_description(relfilenode,'pg_class') as varchar) AS "表名描述",
a.attnum AS "序号",
a.attname AS "列名",
concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '\(.*\)')) as "字段类型",
d.description AS "备注"
from pg_class c
LEFT JOIN pg_attribute a on a.attrelid = c.oid
LEFT JOIN pg_type t on a.atttypid = t.oid
LEFT JOIN pg_description d on a.atttypid = t.oid and d.objsubid=a.attnum
LEFT JOIN pg_namespace ns on ns.oid = c.relnamespace
-- where c.relname = '表名'
where a.attnum>0 and c.relkind = 'r' and ns.nspname = 'public'
ORDER BY c.relname DESC,a.attnum ASC
2. 拷贝查询结构到excel
2.1 拷贝查询结果到excel,然后全选数据,插入表格。
2.2 为每一列增加标题。
参考文档
本文作者: seawish
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!