PostgreSQL查询表以及字段的备注
查询所有表名称以及字段含义
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查询表以及字段的备注的更多相关文章
- PostgreSQL - 查询表结构和索引信息
前言 PostgreSQL的表一般都是建立在public这个schema下的,假如现在有个数据表t_student,可以用以下几种方式来查询表结构和索引信息. 使用\d元命令查看表字段信息和索引信息 ...
- oracle添加字段,备注
1.添加字段: alter table 表名 add (字段 字段类型) [ default '输入默认值'] [null/not null] ; 2.添加备注: comment on ...
- oracle查询表指定字段类型
查询表某字段类型,如下: SELECT data_type FROM all_tab_cols WHERE table_name = UPPER('SRIS_P_BaseInfo') and colu ...
- 解决VS2012上面EF字段说明备注没有的方法
VS2012中的EF有一个BUG 如下: 明明在数据库上面是写有字段说明的到了EF上面就没有了很郁闷: 网络上面有一个解决方法如下: http://www.cnblogs.com/stone_w/ar ...
- mysql 查询表的字段名称,字段类型
select column_name,column_comment,data_type from information_schema.columns where table_name='查询表名称' ...
- PostgreSQL查询表名称及表结构
1. 查询表名称 在psql状态下查询表名称 \dt SQL方式查看表名称 SELECT viewname FROM pg_views WHERE schemaname ='public' Postg ...
- 查询表名和表备注(中文名) 及 dba_tables、all_tables和user_tables的区别
1. select a.* from ALL_TAB_COMMENTS a --查表名和表中文名select a.* from ALL_TAB_COLUMNS a --查询表字段属性select a. ...
- Oracle 查询表中字段里数据是否有重复
1.查找单个字段 select 字段名,count(*) from table group by 字段名 having count(*) > 1 2.查找组合字段: SELECT TEST_NA ...
- Sql Server 2008和2000查询表的字段和注释
-- SQL Server 2008 SELECT 表名 = d.name, 表说明 = case when a.colorder=1 then isnull(f.value,'') else '' ...
随机推荐
- when|nobody|hazard|lane|circuit|
How can I help them they won't listen to me? 题目解析 考查从句.此句意为:如果他们要是不听我的话,我怎么帮助他们?此处,when引导的状语从句表示假设事 ...
- 史上最全Java面试题全集
2013年年底的时候,我看到了网上流传的一个叫做<Java面试题大全>的东西,认真的阅读了以后发现里面的很多题目是重复且没有价值的题目,还有不少的参考答案也是错误的,于是我花了半个月时间对 ...
- supervised learning|unsupervised learning
监督学习即是supervised learning,原始数据中有每个数据有自己的数据结构同时有标签,用于classify,机器learn的是判定规则,通过已成熟的数据training model达到判 ...
- 吴裕雄--天生自然python编程:实例(2)
list1 = [10, 20, 4, 45, 99] list1.sort() print("最小元素为:", *list1[:1]) list1 = [10, 20, 1, 4 ...
- Python实现线程交替打印字符串
import threading con = threading.Condition() word = u"12345上山打老虎" def work(): global word ...
- 从租人APP沦为性工作发布平台 看共享经济监管边界
看共享经济监管边界" title="从租人APP沦为性工作发布平台 看共享经济监管边界"> 继直播类软件部分涉黄之后,最近火爆的各类"租人"软件 ...
- Louis的「每周语文」
说明:此专栏为Louis收录的经典语录及书影音标记,每周一更新. 成长的本质是变得复杂.当你的主观世界遇到客观世界,之间的那条沟,你掉进去,叫挫折,爬出来,叫成长. -- 语出罗振宇在奇葩说第四季的结 ...
- CentOS7 部署K8S集群,最新版1.17.3-0
小白在网上找了很多关于k8s集群部署的文档,但是版本老旧,到处踩坑,终于部署成功,记录下过程. 一.准备工作 虚拟机:VMware® Workstation 15 Pro Xhell 6:Xshell ...
- eggjs+vue+nginx配置
安装node https://github.com/nodesource/distributions#installation-instructions-1 注意使用No root privilege ...
- 小白学 Python 数据分析(10):Pandas (九)数据运算
人生苦短,我用 Python 前文传送门: 小白学 Python 数据分析(1):数据分析基础 小白学 Python 数据分析(2):Pandas (一)概述 小白学 Python 数据分析(3):P ...