select

(select relname||'--'||(select description from pg_description where objoid=oid and objsubid=0) as comment from pg_class where oid=a.attrelid) as table_name,

a.attname as column_name,

format_type(a.atttypid,a.atttypmod) as data_type,

(case when atttypmod-4>0 then atttypmod-4 else 0 end)data_length,

(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

where attstattarget=-1 and attrelid in (select oid from pg_class where relname in(select relname from pg_class where relkind ='r' and relname like 'tbl_%'))

order by table_name,a.attnum;

  

pg 生成数据字典的更多相关文章

  1. 用php生成数据字典

    <?php header("Content-type: text/html; charset=utf-8"); $dbserver = "localhost&quo ...

  2. 使用OpenXml实现生成数据字典文档(beta)

    最近项目在走验收流程,之前没有仔细看SOW文档,发现需要补好多份文档,其中就有数据字典,项目组不愿意花时间太多的时间弄这些文档,也不希望以后还要重复劳动力,最终决定做一个工具,方便自己生成数据字典文档 ...

  3. php生成数据字典,代码

    <?php /** * 生成mysql数据字典 */ header("Content-type:text/html;charset=utf-8"); // 配置数据库 $da ...

  4. 一条SQL生成数据字典

    有个字典表并定期维护,对DBA和开发很重要,终于把他们整合在一起了,看有没问题? 一条SQL生成数据字典,包含所有OPEN用户.表名.字段名.字段序号.字段属性.默认值.是否非空.字段意思.主键标识. ...

  5. SQL server 生成数据字典

    Set nocount on ), ) DECLARE Tbls CURSOR FOR ),isnull(g.[value],'-')) AS TABLE_COMMENT FROM INFORMATI ...

  6. 【PD】PowerDesigner生成数据字典

    1.首先说明我使用的环境 --------------------------------第一种:不按模板导出导出数据字典----------------------------- 2.打开PDM模型 ...

  7. PHP连数据库生成数据字典

    <?php /** * 生成mysql数据字典 */ header("Content-type:text/html;charset=utf-8"); // 配置数据库 $da ...

  8. mysql生成数据字典

    git clone https://github.com/twindb/undrop-for-innodb.git make [root@redis01 undrop-for-innodb]# mak ...

  9. SQL Server 生成 数据字典 / 数据库文档

    1. 工具生成 2.SQL语句生成 参考地址:http://blog.csdn.net/qq289523052/article/details/22174721 1.在 表 上右键 - 扩展属性 - ...

随机推荐

  1. SDOI2019游记

    Day0 一大早就起床,结果忙活了整整一上午. 12:20从gryz出发,路上发现把耳机和笔忘另一个背包里了(都怪老爸非得让我换背包),15:30差不多就到山师了. 山师也是蛮漂亮的,花开得挺好.到处 ...

  2. EditText以及登录UI实现

    EditText是可以输入的文本框 <?xml version="1.0" encoding="utf-8"?><RelativeLayout ...

  3. 请求转发 和 URL 重定向

    五 请求转发 和 URL 重定向 1 请求转发和重定向 干什么用? 是我们在java后台servlet中 由一个servlet跳转到 另一个 servlet/jsp 要使用的技术 前端发送请求到后台 ...

  4. CTF--web 攻防世界web题 robots backup

    攻防世界web题 robots https://adworld.xctf.org.cn/task/answer?type=web&number=3&grade=0&id=506 ...

  5. <03>labview在winCE6.0系统下的程序移植与界面开发

    任务布置:labview与winCE开发<3> 要求一:学会TouchPane的环境配置,建立调试通道:要求二:掌握触控屏幕界面优化: 正文: 今天介绍labview虚拟仪器软件中 Tou ...

  6. markdown 数学公式

    https://blog.csdn.net/zdk930519/article/details/54137476

  7. 小程序 input type number 键盘没有小数点

    在此备注一下: <input type="digit"> number:数字键盘(无小数点)idcard:数字键盘(无小数点.有个 X 键)digit:数字键盘(有小数 ...

  8. Redux thunk中间件

    redux-thunk https://github.com/reduxjs/redux-thunk Why Do I Need This? Thunks are the recommended mi ...

  9. django——个人博客之分页/筛选功能

    在完成了注册.登录后就应该显示主页,在主页中有各种功能的按钮,用户点击后进入后台管理,不同角色的用户根据权限不同显示的页面是不相同的,在个人博客页面会显示自己发布的文章,以及自己的保障记录,在进入后台 ...

  10. 文件共享服务器share

    文件共享服务器:(类似于FTP服务器) 1.创建共享:文件夹右键属性--共享--开启共享--设置共享名--设置共享权限(建议设置为everyone完全控制,然后具体的权限需求在ntfs权限中设置即可) ...