postgresql导出数据库文档
select t.name as "表名",k."属性",k."数据类型",k."长度",k."主键约束",k."唯一约束",
format_type(a.atttypid,a.atttypmod) as "数据类型", (case when atttypmod-4>0 then atttypmod-4 else 0 end) as "长度", (case when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[1]=attnum and contype=‘p‘)>0 then ‘Y‘ else ‘N‘ end) as 主键约束, (case when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[1]=attnum and contype=‘u‘)>0 then ‘Y‘ else ‘N‘ end) as 唯一约束, (case when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[1]=attnum and contype=‘f‘)>0 then ‘Y‘ else ‘N‘ end) as 外键约束, (case when a.attnotnull=true then ‘Y‘ else ‘N‘ end) as nullable, col_description(a.attrelid,a.attnum) as comment from pg_attribute a )k ? 参考:https://www.cnblogs.com/nami/p/4112339.html http://www.cnblogs.com/jxycn/p/5215822.html?locationNum=6&fps=1 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |