摘要:查询所有表名称以及字段含义表名名称字段字段备注列类型查看所有表名查看表名和备注查看特定表名备注查看特定表名字段
查询所有表名称以及字段含义
</>复制代码
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 ="tbl_alarm";
查看特定表名字段
</>复制代码
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="tbl_alarm" and a.attnum>0 and a.attrelid=c.oid and a.atttypid=t.oid and d.objoid=a.attrelid and d.objsubid=a.attnum;
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/39026.html
摘要:今天在坛子里有人提出了一个问题,问题是这样的在以下指定表中中国辽宁山东沈阳大连济南和平区沈河区现在给定一个号,想得到它完整的名字。递归往上找,直到为止。也就是最高层级时结束,求完整语句。 今天在坛子里有人提出了一个问题,问题是这样的:在以下指定表中 id name fatherid1 中国 02 辽宁 13 山东 14 沈阳 25 大连 26 济南 37 和平区 48 沈河区 4 现在...
摘要:常见类型直接兼容的数组类型。如的,对应的数据源格式,既支持键值对,又支持。书写格式遵守官方规范。格式,支持前缀。其中用户名端口主机名,在数据源中未指定时,有默认值。这能提高倍的执行速度为了发挥好此功能,需要最大可能地允许数据库连接空闲。 用于golang database/sql 的PostgreSQL驱动 showImg(https://godoc.org/github.com/bl...
阅读 1166·2023-04-25 14:45
阅读 2944·2021-09-30 09:59
阅读 3219·2021-09-22 15:48
阅读 2528·2019-08-30 15:55
阅读 3660·2019-08-30 15:44
阅读 648·2019-08-29 14:07
阅读 3503·2019-08-26 13:45
阅读 629·2019-08-26 11:31