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

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. JavaScript设计模式一:工厂模式和构造器模式

    转自:http://segmentfault.com/a/1190000002525792 什么是模式 前阵子准备期末考试,挺累也挺忙的,实在闲不得空来更新文章,今天和大家说说javascript中的 ...

  2. python中coding:utf-8的作用

    或者

  3. 吴裕雄--天生自然 神经网络人工智能项目:基于深度学习TENSORFLOW框架的图像分类与目标跟踪报告(续四)

    2. 神经网络的搭建以及迁移学习的测试 7.项目总结 通过本次水果图片卷积池化全连接试验分类项目的实践,我对卷积.池化.全连接等相关的理论的理解更加全面和清晰了.试验主要采用python高级编程语言的 ...

  4. mysql-5.7.25解压版本安装和navicat 12.1版本破解-4.8破解工具

    1.配置环境变量 百度网盘下载https://pan.baidu.com/s/1tbOJiOG9l87HbIzsLApX4A 提取码  t657  (mysql-5.7.25大小300M解压后1.6G ...

  5. 【XP系统下载U盘装系统】用电脑店超级U盘装XP系统详细图文教程

    现在U盘装系统已经越来越流行了,不仅方便而且简单,由于U盘启动盘用的制作工具不同,其中比较流行的有老毛桃.电脑店.大白菜.一键U盘装系统等等,因此安装过程中也有不尽相同的,今天就和大家分享下利用电脑店 ...

  6. Python建立web静态服务器

    原文地址:http://www.bugingcode.com/blog/python_html_web_server.html python作为工具,提供了很多好用的命令,比如有时候突然需要建立一个解 ...

  7. Leetcode 412.FizzBuzz

    题目描述 写一个程序,输出从 1 到 n 数字的字符串表示. 1. 如果 n 是3的倍数,输出"Fizz": 2. 如果 n 是5的倍数,输出"Buzz": 3 ...

  8. 每天一个linux命令(15)-tail

    tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不断刷新, ...

  9. 创建 GPG 证书

    一.什么是 GPG 以下引自维基百科: GNU Privacy Guard(GnuPG或GPG)是一种加密软件,它是PGP加密软件的满足GPL的替代物.GnuPG依照由IETF订定的OpenPGP技术 ...

  10. CSS 技巧汇总

    CSS 选择符优先级 !important 声明>内联样式(style)>id 选择符(#id)>类选择符(.class)=伪类选择符(:hover )=属性选择符([attr] ) ...