第1页 / 共1页
PostgreSQL获取表名和字段名.docx
PostgreSQL 获取数据库中所有 table 名:
[sql] view plaincopy
tablename
tablename
1. SELECT
2. WHERE
LIKE
3. AND tablename NOT LIKE 'sql_%'
4. ORDER
FROM
NOT
tablename;
BY
pg_tables
'pg%'
PostgreSQL 获取数据库中所有 table 名及 table 的注解信息:
[sql] view plaincopy
1. SELECT
tablename,obj_description(relfilenode,'pg_class')
FROM
pg_tables
a, pg_class b
2. WHERE
3. a.tablename = b.relname
4. and a.tablename
5. AND a.tablename NOT LIKE 'sql_%'
6. ORDER
a.tablename;
LIKE
NOT
BY
'pg%'
PostgreSQL 获取指定 table 的所有字段信息:
[sql] view plaincopy
1. SELECT col_description(a.attrelid,a.attnum) as comment,format_type(a.atttypi
d,a.atttypmod) as type,a.attname as name, a.attnotnull as notnull
2. FROM pg_class as c,pg_attribute as a
3. where c.relname = 'tablename' and a.attrelid = c.oid and a.attnum>0
相关推荐
- 2023年江西萍乡中考道德与法治真题及答案.doc
- 2012年重庆南川中考生物真题及答案.doc
- 2013年江西师范大学地理学综合及文艺理论基础考研真题.doc
- 2020年四川甘孜小升初语文真题及答案I卷.doc
- 2020年注册岩土工程师专业基础考试真题及答案.doc
- 2023-2024学年福建省厦门市九年级上学期数学月考试题及答案.doc
- 2021-2022学年辽宁省沈阳市大东区九年级上学期语文期末试题及答案.doc
- 2022-2023学年北京东城区初三第一学期物理期末试卷及答案.doc
- 2018上半年江西教师资格初中地理学科知识与教学能力真题及答案.doc
- 2012年河北国家公务员申论考试真题及答案-省级.doc
- 2020-2021学年江苏省扬州市江都区邵樊片九年级上学期数学第一次质量检测试题及答案.doc
- 2022下半年黑龙江教师资格证中学综合素质真题及答案.doc