COMMENT ON

A DDL command for defining, modifying or removing an object comment

COMMENT ON is a DDL command for defining, modifying or removing an object comment.

COMMENT ON was added in PostgreSQL 7.0.

Support functions

The following system functions provide SQL-level support for extracting object comments:

Change history

Examples

Add a comment to a table:

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)

Modify a comment on a table:

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)

Remove a comment from a table:

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 documentation: COMMENT

Categories

DDL, SQL command

See also

pg_description, pg_shdescription