COMMENT ON
是一个 DDL 命令,用于定义、修改或删除对象注释。
COMMENT ON
添加于 PostgreSQL 7.0。
支持函数
以下系统函数提供 SQL 级别的支持,用于提取对象注释
更改历史记录
- PostgreSQL 11
- PostgreSQL 10
- PostgreSQL 9.6
COMMENT ON ACCESS METHOD
已添加(提交 4f04b66f)
- PostgreSQL 9.5
- PostgreSQL 9.3
- PostgreSQL 9.1
- PostgreSQL 8.3
- PostgreSQL 8.2
- PostgreSQL 8.0
- PostgreSQL 7.3
- PostgreSQL 7.0
- 已添加(提交 7acc2377)
示例
向表添加注释
postgres=# COMMENT ON TABLE foo IS 'Store all the things'; COMMENT postgres=# \dt+ foo List of relations Schema | Name | Type | Owner | Persistence | Access Method | Size | Description --------+------+-------+----------+-------------+---------------+---------+---------------------- public | foo | table | postgres | permanent | heap | 0 bytes | Store all the things (1 row)
修改表上的注释
postgres=# COMMENT ON TABLE foo IS 'Store most of the things'; COMMENT postgres=# \dt+ foo List of relations Schema | Name | Type | Owner | Persistence | Access Method | Size | Description --------+------+-------+----------+-------------+---------------+---------+-------------------------- public | foo | table | postgres | permanent | heap | 0 bytes | Store most of the things (1 row)
从表中删除注释
postgres=# COMMENT ON TABLE foo IS NULL; COMMENT postgres=# \dt+ foo List of relations Schema | Name | Type | Owner | Persistence | Access Method | Size | Description --------+------+-------+----------+-------------+---------------+---------+------------- public | foo | table | postgres | permanent | heap | 0 bytes | (1 row)
参考文献
- PostgreSQL 文档: COMMENT