PostgreSQL获取table名,字段名
Posted 十光年
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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名,字段名的主要内容,如果未能解决你的问题,请参考以下文章