1. 程式人生 > >postgresql資料表和欄位名的獲取

postgresql資料表和欄位名的獲取

pg庫表名獲取

select * from pg_tables where tablename=‘’

pg庫列名和型別註釋等獲取

–獲取欄位名、型別、註釋、是否為空:
SELECT col_description(a.attrelid,a.attnum) as comment,a.attname as name,format_type(a.atttypid,a.atttypmod) as type, a.attnotnull as notnull
FROM pg_class as c,pg_attribute as a where c.relname = ‘table_name’ and a.attrelid = c.oid and col_description(a.attrelid,a.attnum) is not null;