码迷,mamicode.com
首页 > 数据库 > 详细

PostgreSQL获取table名,字段名

时间:2017-06-17 20:37:34      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:get   ase   mysql   name   blog   nbsp   数据   net   class   

PostgreSQL获取数据库中所有table名:

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

 

PostgreSQL获取数据库中所有table名及table的注解信息:

SELECT tablename,
        obj_description(relfilenode,
        pg_class)
FROM pg_tables a, pg_class b
WHERE a.tablename = b.relname
        AND a.tablename NOT LIKE pg%
        AND a.tablename NOT LIKE sql_%
ORDER BY  a.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

 

PostgreSQL获取table名,字段名

标签:get   ase   mysql   name   blog   nbsp   数据   net   class   

原文地址:http://www.cnblogs.com/jun1019/p/7041103.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!