COMMENT ON

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

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

COMMENT ONPostgreSQL 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)

分类

DDL, SQL 命令

另请参阅

pg_description, pg_shdescription

反馈

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