select
(select relname from pg_class where oid=a.attrelid) relname ,
(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[]=attnum and contype='p')>0 then 'Y' else 'N' end) as 主键约束, (case when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[]=attnum and contype='u')>0 then 'Y' else 'N' end) as 唯一约束, (case when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[]=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 not like 'pg_%' )) order by relname,a.attnum;

PostgreSql 查询表结构和说明的更多相关文章

  1. PostgreSQL - 查询表结构和索引信息

    前言 PostgreSQL的表一般都是建立在public这个schema下的,假如现在有个数据表t_student,可以用以下几种方式来查询表结构和索引信息. 使用\d元命令查看表字段信息和索引信息 ...

  2. PostgreSQL查询表名称及表结构

    1. 查询表名称 在psql状态下查询表名称 \dt SQL方式查看表名称 SELECT viewname FROM pg_views WHERE schemaname ='public' Postg ...

  3. Postgresql查询表和表结构

    查询表名 SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg%' AND tablename NOT LIKE 'sql_%' O ...

  4. sql server 查询表结构

    --查询表结构start SELECT 序号 = a.colorder,字段名称 = a.name,字段描述 = f.value, 标识 then '√' else '' end, 主键 FROM s ...

  5. Sqlserver查询表结构信息-字段说明、类型、长度等信息

    Sqlserver 中查询表结构信息-字段说明.类型.长度等信息综合语法. SELECT 表名 = d.name,--case when a.colorder=1 then d.name else ' ...

  6. <经验杂谈>查询表结构的SQL语句

    在我们使用SQL数据库的过程中,经常会遇到查询表结构的情况,以下就是sql语句的写法: --查询非系统数据库 SELECT name FROM Master..SysDatabases 查询数据库下所 ...

  7. Oracle查询表结构的常用语句

    1. 查询表结构基本信息 select * from user_tables t,user_tab_comments c where c.table_name = t.table_name and t ...

  8. SQL语句查询表结构

    SQL语句查询表结构   刚刚在做一个小项目,数据库中一张表有20来个字段,用我以前做的一个.NET实体类生成器一个一个的输入还是闲麻烦,于是打算找个时间来重新的改造一个那个.NET实体类,能够通过选 ...

  9. SQLServer中查询表结构(表主键 、列说明、列数据类型、所有表名)的Sql语句

    SQLServer中查询表结构(表主键 .列说明.列数据类型.所有表名)的Sql语句 1.查询数据库中的所有表名称: SELECT name FROM SysObjects Where XType=' ...

随机推荐

  1. vue中央事件总线eventBus的简单理解和使用

    公共事件总线eventBus的实质就是创建一个vue实例,通过一个空的vue实例作为桥梁实现vue组件间的通信.它是实现非父子组件通信的一种解决方案. 用法如下: 第一步:项目中创建一个js文件(我通 ...

  2. scala时间和时间戳互转

    时间转换为时间戳: import java.text.SimpleDateFormat object test { def main(args: Array[String]): Unit = { va ...

  3. Python内置函数(35)——issubclass

     英文文档: issubclass(class, classinfo) Return true if class is a subclass (direct, indirect or virtual) ...

  4. 微信小程序实战–集阅读与电影于一体的小程序项目(八)

    31.电影详情页面 movie-template.wxml <view class="movie-container" catchtap="onMovieTap&q ...

  5. RxJS 实现摩斯密码(Morse) 【内附脑图】

    参加 2018 ngChina 开发者大会,特别喜欢 Michael Hladky 奥地利帅哥的 RxJS 分享,现在拿出来好好学习工作坊的内容(工作坊Demo地址),结合这个示例,做了一个改进版本, ...

  6. 一篇文章彻底搞懂es6 Promise

    前言 Promise,用于解决回调地狱带来的问题,将异步操作以同步的操作编程表达出来,避免了层层嵌套的回调函数. 既然是用来解决回调地狱的问题,那首先来看下什么是回调地狱 var sayhello = ...

  7. nginx部署dotnet core站点

    步骤 aspnetcore程序端口号5001,实际外部端口号8001,相当于把8001收到的请求转发给5001. 把发布出来的文件全部丢掉 /var/www/JuXiangTou 里面去.可以用scp ...

  8. Lily_music 网页音乐播放器 -可搜索(附歌词联动播放效果解说)

    博客地址:https://ainyi.com/59 写在前面 这是我今年(2018)年初的小项目,当时也是手贱,不想用别的播放器,想着做一个自己的网页播放器,有个歌曲列表.可关键词搜索.歌词滚动播放的 ...

  9. Paypal 支付功能的 C# .NET / JS 实现

    说明 最近用到了 Paypal 支付功能,英语一般般的我也不得不硬着头皮踩一踩这样的坑.经过近乎半个月的作,终于实现了简单的支付功能,那么首先就说说使用 Paypal 必定要知道的几点(当前日期 20 ...

  10. 冒泡排序/选择排序/插入排序(c#)

    ---恢复内容开始--- 每次看这些排序都像没见过一样,完全理解不了,可是不久前明明了解的十分透彻.记下来记下来记下来! 1>>>冒泡排序:相邻的两两相比 把大的(或者小的)放后边, ...