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

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