USEGEAR

导航

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'

 

posted on 2021-08-21 17:02  USEGEAR  阅读(53)  评论(0编辑  收藏  举报