PostgreSQL 获取表字段信息的语句

好不容易搞成,做个笔记

写道
SELECT col_description(a.attrelid,a.attnum) as comment,format_type(a.atttypid,a.atttypmod) as type,a.attname as name, a.attnotnull as notnull
FROM pg_class as c,pg_attribute as a
where c.relname = 'tablename' and a.attrelid = c.oid and a.attnum>0

 tablename就是表名了

你可能感兴趣的:(零碎儿)