pg_description
是一个存储数据库对象注释的系统目录表。
pg_description
添加于PostgreSQL 6.3。
目的
pg_description
存储由 COMMENT ON
命令定义的当前数据库中对象的任意用户定义描述。
有关全局对象(角色、表空间等)的注释,请参见 pg_shdescription
。
按 PostgreSQL 版本定义
pg_description (PostgreSQL 17)
Table "pg_catalog.pg_description" Column | Type | Collation | Nullable | Default -------------+---------+-----------+----------+--------- objoid | oid | | not null | classoid | oid | | not null | objsubid | integer | | not null | description | text | C | not null | Indexes: "pg_description_o_c_o_index" PRIMARY KEY, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 16)
Table "pg_catalog.pg_description" Column | Type | Collation | Nullable | Default -------------+---------+-----------+----------+--------- objoid | oid | | not null | classoid | oid | | not null | objsubid | integer | | not null | description | text | C | not null | Indexes: "pg_description_o_c_o_index" PRIMARY KEY, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 15)
Table "pg_catalog.pg_description" Column | Type | Collation | Nullable | Default -------------+---------+-----------+----------+--------- objoid | oid | | not null | classoid | oid | | not null | objsubid | integer | | not null | description | text | C | not null | Indexes: "pg_description_o_c_o_index" PRIMARY KEY, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 14)
Table "pg_catalog.pg_description" Column | Type | Collation | Nullable | Default -------------+---------+-----------+----------+--------- objoid | oid | | not null | classoid | oid | | not null | objsubid | integer | | not null | description | text | C | not null | Indexes: "pg_description_o_c_o_index" PRIMARY KEY, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 13)
Table "pg_catalog.pg_description" Column | Type | Collation | Nullable | Default -------------+---------+-----------+----------+--------- objoid | oid | | not null | classoid | oid | | not null | objsubid | integer | | not null | description | text | C | not null | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 12)
Table "pg_catalog.pg_description" Column | Type | Collation | Nullable | Default -------------+---------+-----------+----------+--------- objoid | oid | | not null | classoid | oid | | not null | objsubid | integer | | not null | description | text | C | not null | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 11)
Table "pg_catalog.pg_description" Column | Type | Collation | Nullable | Default -------------+---------+-----------+----------+--------- objoid | oid | | not null | classoid | oid | | not null | objsubid | integer | | not null | description | text | | not null | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 10)
Table "pg_catalog.pg_description" Column | Type | Collation | Nullable | Default -------------+---------+-----------+----------+--------- objoid | oid | | not null | classoid | oid | | not null | objsubid | integer | | not null | description | text | | not null | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 9.6)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | not null Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 9.5)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | not null Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 9.4)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 9.3)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 9.2)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 9.1)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 9.0)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 8.4)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 8.3)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
pg_description (PostgreSQL 8.2)
Table "pg_catalog.pg_description" Column | Type | Modifiers -------------+---------+----------- objoid | oid | not null classoid | oid | not null objsubid | integer | not null description | text | Indexes: "pg_description_o_c_o_index" UNIQUE, btree (objoid, classoid, objsubid)
文档: pg_description
更改历史记录
- PostgreSQL 9.5
- 列
description
设置为NOT NULL
(提交 82a532b3)
- 列
- PostgreSQL 7.2
- 添加以下列 (提交 bf56f075)
classoid
objsubid
- 添加以下列 (提交 bf56f075)
- PostgreSQL 6.3
- 添加 (提交 5071ae29)
示例
向表添加注释
postgres=# COMMENT ON TABLE foo IS 'Store all the things'; COMMENT postgres=# SELECT * FROM pg_description WHERE objoid = 'foo'::REGCLASS; objoid | classoid | objsubid | description --------+----------+----------+---------------------- 16470 | 1259 | 0 | Store all the things (1 row)
从表中删除注释
postgres=# COMMENT ON TABLE foo IS NULL; COMMENT postgres=# SELECT * FROM pg_description WHERE objoid = 'foo'::REGCLASS; objoid | classoid | objsubid | description --------+----------+----------+------------- (0 rows)
参考
- PostgreSQL 文档: pg_description