PostgreSQL 获取数据库中所有 table 名:
[sql] view plaincopy
tablename
tablename
1. SELECT
2. WHERE
LIKE
3. AND tablename NOT LIKE 'sql_%'
4. ORDER
FROM
NOT
tablename;
BY
pg_tables
'pg%'
PostgreSQL 获取数据库中所有 table 名及 table 的注解信息:
[sql] view plaincopy
1. SELECT
tablename,obj_description(relfilenode,'pg_class')
FROM
pg_tables
a, pg_class b
2. WHERE
3. a.tablename = b.relname
4. and a.tablename
5. AND a.tablename NOT LIKE 'sql_%'
6. ORDER
a.tablename;
LIKE
NOT
BY
'pg%'
PostgreSQL 获取指定 table 的所有字段信息:
[sql] view plaincopy
1. SELECT col_description(a.attrelid,a.attnum) as comment,format_type(a.atttypi
d,a.atttypmod) as type,a.attname as name, a.attnotnull as notnull
2. FROM pg_class as c,pg_attribute as a
3. where c.relname = 'tablename' and a.attrelid = c.oid and a.attnum>0