3大schema
2个基本的schema:
information_schema
pg_catalog
然后还有个默认的schema,就是public。
创建表时,如果不指定的schema,那么默认在public下创建表。
information_schema和pg_catalog相当于库,所以查询的时候后面一定要加点号指定范围:
以下2种错误写法:
select * from information_schema; 错
select * from pg_catalog; 错
因为pg_catalog相当于是数据库,这种语句肯定不对。
pg_description表
想要查看注释肯定离不开pg_description表。
共有4列:
字段 | 描述 |
---|---|
objoid | 所属对象的OID(表oid) |
classoid | 对象所属系统目录的OID(pg_class的oid) |
objsubid | 列序号,详细描述我也没看懂:[对于一个表列上的一个注释,这里是列号(objoid和classoid指表本身)。对所有其他对象类型,此列为0。] |
description | 描述文本 |
注: 根据表名找到oid之后,这里要用objoid关联(不要用classoid哦)。
查看表的注释:
select oid from pg_class where relname='t_user';
select * from pg_description where objoid='从pg_class查出的oid';
pg_attribute表
这个表字段比较多,常用的字段有:
字段 | 描述 |
---|---|
attrelid | 此字段所属的表,值为对应表的odi,也就是pg_class.oid。 |
attname | 字段名 |
atttypid | 字段的数据类型,值为pg_type.oid |
attnum | 字段的编号,普通字段是从1开始计数的。系统字段,如oid,是任意的负数 |