PostgreSql生成数据字典
Posted TurboWay
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PostgreSql生成数据字典相关的知识,希望对你有一定的参考价值。
pg查询元数据,生成表数据字典:
效果:
代码:
SELECT A .attname 字段, concat_ws ( \'\', T .typname, SUBSTRING ( format_type (A .atttypid, A .atttypmod) FROM \'\\(.*\\)\' ) ) AS 类型, case when s.pk is not null then \'是\' else \'否\' end as 主键, case A.attnotnull when \'f\' then \'是\' when \'t\' then \'否\' end as 空, d.description 注释 FROM pg_attribute A INNER JOIN pg_class C on A .attrelid = C .oid INNER JOIN pg_type T on A .atttypid = T .oid LEFT JOIN (SELECT conrelid, unnest(conkey) as pk FROM pg_constraint WHERE contype = \'p\') S ON S.conrelid = C .oid AND A.attnum = S.pk LEFT JOIN pg_description d on d.objoid = A .attrelid AND d.objsubid = A .attnum LEFT JOIN pg_namespace n on n.oid = c.relnamespace WHERE A.attnum > 0 AND n.nspname = \'public\' AND C.relname = \'t_gfecp_bigdata_blacklist\' ORDER BY C .relname, A .attnum
以上是关于PostgreSql生成数据字典的主要内容,如果未能解决你的问题,请参考以下文章