study PostgreSQL【3-get数据库中all表以及表的字段信息】

时间:2021-08-21 20:00:37   收藏:0   阅读:17

get一表的字段相关信息:

SELECT  col_description(a.attrelid,a.attnum) as comment,pg_type.typname as typename,a.attname as name, a.attnotnull as notnull
FROM pg_class as c,pg_attribute as a inner join pg_type on pg_type.oid = a.atttypid
where c.relname = ‘表名‘ and a.attrelid = c.oid and a.attnum>0;

-----------------------------
SELECT * 
FROM pg_class as c,pg_attribute as a inner join pg_type on pg_type.oid = a.atttypid
where c.relname = ‘表名‘ and a.attrelid = c.oid and a.attnum>0

get表名:

select * from  pg_tables where schemaname=‘public‘

 

原文:https://www.cnblogs.com/usegear/p/15170004.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!