首页 > 代码库 > PostgreSQL获取table名,字段名
PostgreSQL获取table名,字段名
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名,字段名
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。