PostgreSQL获取数据库中所有table名:
SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg%' AND tablename NOT LIKE 'sql_%' ORDER BY tablename;
PostgreSQL获取指定table的所有字段信息:
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
本文介绍如何使用SQL语句从PostgreSQL数据库中查询所有表名及指定表的所有字段信息,包括字段的数据类型、名称、是否允许为空等属性。
1629

被折叠的 条评论
为什么被折叠?



