PostgreSQL-查询表的字段(属性)定义-pg_attribute

pg_attribute表中存储了每个表的属性信息,此表的 pg_attribute.attrelid字段是每个表在对应的 pg_class.oid的值。
例如获取pg_attribute表自己的字段定义信息的命令如下:

select
	attrelid,
	attnum,
	attname,
	attnotnull
from
	pg_attribute
where
	attrelid = (select oid from pg_class where relname = 'pg_attribute') order by attnum;

查询结果

 attrelid | attnum |    attname    | attnotnull
----------+--------+---------------+------------
     1249 |     -7 | tableoid      | t
     1249 |     -6 | cmax          | t
     1249 |     -5 | xmax          | t
     1249 |     -4 | cmin          | t
     1249 |     -3 | xmin          | t
     1249 |     -1 | ctid          | t
     1249 |      1 | attrelid      | t
     1249 |      2 | attname       | t
     1249 |      3 | atttypid      | t
     1249 |      4 | attstattarget | t
     1249 |      5 | attlen        | t
     1249 |      6 | attnum        | t
     1249 |      7 | attndims      | t
     1249 |      8 | attcacheoff   | t
     1249 |      9 | atttypmod     | t
     1249 |     10 | attbyval      | t
     1249 |     11 | attstorage    | t
     1249 |     12 | attalign      | t
     1249 |     13 | attnotnull    | t
     1249 |     14 | atthasdef     | t
     1249 |     15 | attidentity   | t
     1249 |     16 | attisdropped  | t
     1249 |     17 | attislocal    | t
     1249 |     18 | attinhcount   | t
     1249 |     19 | attcollation  | t
     1249 |     20 | attacl        | f
     1249 |     21 | attoptions    | f
     1249 |     22 | attfdwoptions | f
(28 rows)

参考文档

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值