COMMENT ON

用于操作对象注释的 SQL 命令

COMMENT ON 是一个 DDL 命令,用于定义、修改或删除对象注释。

COMMENT ON 添加于 PostgreSQL 7.0

支持函数

以下系统函数提供 SQL 级别的支持,用于提取对象注释

更改历史记录

示例

向表添加注释

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)

类别

DDLSQL 命令

另请参阅

pg_descriptionpg_shdescription

反馈

提交任何关于“COMMENT ON”的评论、建议或更正 此处