查询所有表名称以及字段含义

select c.relname 表名,cast(obj_description(relfilenode,'pg_class') as varchar) 名称,a.attname 字段,d.description 字段备注,concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '\(.*\)')) as 列类型 from pg_class c,pg_attribute a,pg_type t,pg_description d
where a.attnum>0 and a.attrelid=c.oid and a.atttypid=t.oid and d.objoid=a.attrelid and d.objsubid=a.attnum
and c.relname in (select tablename from pg_tables where schemaname='public' and position('_2' in tablename)=0) order by c.relname,a.attnum

查看所有表名

select tablename from pg_tables where schemaname='public' and position('_2' in tablename)=0;

select * from pg_tables;

查看表名和备注

select relname as tabname,cast(obj_description(relfilenode,'pg_class') as varchar) as comment from pg_class c
where relname in (select tablename from pg_tables where schemaname='public' and position('_2' in tablename)=0); select * from pg_class;

查看特定表名备注

select relname as tabname,
cast(obj_description(relfilenode,'pg_class') as varchar) as comment from pg_class c
where relname ='表名';

查看特定表名字段

select a.attnum,a.attname,concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '\(.*\)')) as type,d.description from pg_class c,pg_attribute a,pg_type t,pg_description d
where c.relname='表名' and a.attnum>0 and a.attrelid=c.oid and a.atttypid=t.oid and d.objoid=a.attrelid and d.objsubid=a.attnum;

PostgreSQL查询表以及字段的备注的更多相关文章

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

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

  2. oracle添加字段,备注

    1.添加字段: alter table  表名  add (字段  字段类型)  [ default  '输入默认值']  [null/not null]  ; 2.添加备注: comment on ...

  3. oracle查询表指定字段类型

    查询表某字段类型,如下: SELECT data_type FROM all_tab_cols WHERE table_name = UPPER('SRIS_P_BaseInfo') and colu ...

  4. 解决VS2012上面EF字段说明备注没有的方法

    VS2012中的EF有一个BUG 如下: 明明在数据库上面是写有字段说明的到了EF上面就没有了很郁闷: 网络上面有一个解决方法如下: http://www.cnblogs.com/stone_w/ar ...

  5. mysql 查询表的字段名称,字段类型

    select column_name,column_comment,data_type from information_schema.columns where table_name='查询表名称' ...

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

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

  7. 查询表名和表备注(中文名) 及 dba_tables、all_tables和user_tables的区别

    1. select a.* from ALL_TAB_COMMENTS a --查表名和表中文名select a.* from ALL_TAB_COLUMNS a --查询表字段属性select a. ...

  8. Oracle 查询表中字段里数据是否有重复

    1.查找单个字段 select 字段名,count(*) from table group by 字段名 having count(*) > 1 2.查找组合字段: SELECT TEST_NA ...

  9. Sql Server 2008和2000查询表的字段和注释

    -- SQL Server 2008 SELECT 表名 = d.name, 表说明 = case when a.colorder=1 then isnull(f.value,'') else '' ...

随机推荐

  1. Scarpy框架安装教程

    在一切之前,建议升级pip,如果版本太低,安装会失败 升级pip命令: python -m pip install --upgrade pip 如果上面的命令不能用,用下面这个 easy_instal ...

  2. 在Docker内安装jenkins运行和基础配置

    这里是在linux环境下安装docker之后,在doucer内安装jenkins --------------------docker 安装 jenkins---------------------- ...

  3. Python实现链表倒序(带头指针)

    class ListNode(object): def __init__(self, x): self.val = x self.next = None def reverseList(self, h ...

  4. leetcode_315_逆序对问题

    题目描述 本题来自于Leetcode的算法题库第315题,具体题目描述如下: 给定一个nums整数数组 ,按要求返回一个counts新数组 .数组 counts 有该性质: counts[i]的值是 ...

  5. JDK_Packages_java_utils

    utils包需要关注的主要有 ​ 集合框架.并发包.函数式编程.观察者模式@see PropertyChangeSupport java.util(集合框架) Contains the collect ...

  6. 算法拾遗[4]——STL用法

    主要bb一下优先队列和字符串吧. 哦还有 bitset. 优先队列 定义很容易: priority_queue<int> pq; 内部是一个堆. 基本操作 pq.top() 取堆顶元素; ...

  7. nginx 502排错

    线上一台机器(该论坛所在机器)近期频繁出现502,每100次访问就会出现10次,这频率也太高了.于是开始了我的502排查之旅 ps aux |grep -c php 结果为200 netstat -a ...

  8. cordova+jquery form上传里面的一些诡异坑

    在浏览器里面执行很正常的代码,打包到手机上测试就出问题了,浏览器中的执行版本如下: <!DOCTYPE html> <html lang="en"> < ...

  9. 5种方法获取url中文件的扩展名

    /** * strrchr - 查找指定字符在字符串中的最后一次出现 * strrpos — 计算指定字符串在目标字符串中最后一次出现的位置 * end — 将数组的内部指针指向最后一个单元 * pa ...

  10. Eclipse-project-clean

    project--->clean的原理 eclipse  --->project  ----->clean... 选项将工程中的.class文件删除,同时重新编译工程,类似于jbui ...