PostgreSQL获取table名,字段名

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,C++,c,C#,PostgreSQL)