Postgresql查询表和表结构

查询表名

SELECT   tablename   FROM   pg_tables
WHERE   tablename   NOT   LIKE   'pg%'
AND tablename NOT LIKE 'sql_%'
 ORDER   BY   tablename;

或者

select tablename from pg_tables where schemaname='public'

查询表结构

select
col.table_schema,
col.table_name,
col.ordinal_position,
col.column_name,
col.data_type,
col.character_maximum_length,
col.numeric_precision,
col.numeric_scale,
col.is_nullable,
col.column_default,
des.description
from
information_schema.columns col left join pg_description des on
col.table_name::regclass = des.objoid
and col.ordinal_position = des.objsubid
where
table_schema = 'public'
and table_name = 'table_name'
order by
ordinal_position;
上一篇:DES算法图解(来自网络整理)


下一篇:[IOI 2011]ricehub