Postgres中数据字典的用法(二)

本文主要探讨了Postgres数据库中的数据字典,详细解析了pg_attribute和pg_constraint两个重要部分,它们分别记录表的属性信息和约束条件。同时,分享了用于查看数据库关系表的实用SQL查询,包括获取字段详情、主键信息、序列和列信息等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

4.pg_attribute

postgres=# \d+ pg_attribute;
                          数据表 "pg_catalog.pg_attribute"
     栏位      |   类型    |  可空的  |   存储   | 描述
---------------+-----------+----------+----------+------
 attrelid      | oid       | not null | plain    |列所属的表
 attname       | name      | not null | plain    |列名
 atttypid      | oid       | not null | plain    |列的数据类型
 attstattarget | integer   | not null | plain    |attstattarget控制由ANALYZE对此列收集的统计信息的细节层次。
 attlen        | smallint  | not null | plain    |本列类型的pg_type.typlen一个拷贝
 attnum        | smallint  | not null | plain    |列的编号
 attndims      | integer   | not null | plain    |如果该列是一个数组类型,这里就是其维度数;否则为0。
 attcacheoff   | integer   | not null | plain    |在存储中总是为-1
 atttypmod     | integer   | not null | plain    |atttypmod记录了在表创建时提供的类型相关数据
 attbyval      | boolean   | not null | plain    |该列类型的pg_type.typbyval的一个拷贝
 attstorage    | "char"    | not null | plain    |通常是该列类型的pg_type.typstorage的一个拷贝
 attalign      | "char"    | not null | plain    |通常是该列类型的pg_type.typalign的一个拷贝该列类型的pg_type.typstorage的一个拷贝。
 attnotnull    | boolean   | not null | plain    |这表示一个非空约束
 atthasdef     | boolean   | not null | plain    |该列有一个默认值,在此情况下在pg_attrdef目录中会有一个对应项来真正记录默认值。
 atthasmissing | boolean   | not 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值