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 '' ...
随机推荐
- jmeter如何解决乱码问题
使用jmeter的时候时常遇到中文乱码的情况,下面总结一下几个解决方法,方便以后进行复习. 1.添加后置处理器Beanshell PostProcessor,在输入框内写入“prve.setDateE ...
- 接口测试-chap4-关联接口测试
关联接口测试指:请求第2个接口之前必须先请求第一个接口 1.请求第2个接口时需要带着第一个请求返回的cookie 2.如果不使用cookie,如何进行关联接口测试:使用session保持连接.可以代替 ...
- Nginx笔记总结一:基本安装和配置
1. Nginx安装 下载地址和安装依赖包 http://nginx.org/download/nginx-1.9.14.tar.gz yum -y install pcre pcre-devel z ...
- geoserver整合swagger2支持自动生成API文档
网上各种博客都有关于swagger2集成到springmvc.springboot框架的说明,但作者在整合到geoserver中确碰到了问题,调试一番最后才解决,遂总结一下. swagger2集成只需 ...
- Spring常用注解(讲解的通俗易懂,很透彻)
使用注解来构造IoC容器 用注解来向Spring容器注册Bean.需要在applicationContext.xml中注册<context:component-scan base-package ...
- java 字符串转日期格式
/** * 字符串转日期格式 * */ public static Date date(String date_str) { try { Calendar zcal = Calendar.getIns ...
- 概念--Maven仓库
转:Maven:mirror和repository 区别 Tip: 默认中央仓库的地址:https://repo.maven.apache.org/maven2 1.Maven仓库主要有2种 remo ...
- mvn -v报java.lang.ClassNotFoundException
Tips: 比如要下载版本3.2.5的,请选择binaries下的apache-maven-3.2.5-bin.zip. binaries 指的是可以执行的. source 指的源码. 下载地址:ht ...
- Servlet+JSP 对外访问路径配置
servlet类似 servlet配置为: <servlet> <servlet-name>Demo01_OutWrite</servlet-name> ...
- HTTP 协议的基本知识,包括请求流程、请求方法等
一.什么是http协议? HTTP是Hyper Text Transfer Protocol(超文本传输协议)的缩写.它的发展是万维网协会(World Wide Web Consortium)和Int ...