If you want to remove an existing comment on a table or column, rewrite the current comment with NULL.

Syntax

COMMENT ON <object_type> <relation_name>.<object_name> IS <comment>

Parameters

ParameterNotes
object_typeType of the object that you want to add comments to. Allowed values: TABLE, COLUMN.
relation_name.object_nameName of the object that you want to add comments to. For columns, you also need to specify the table name.
commentComment that you want to add.

Examples

Add a comment on a table:

COMMENT ON TABLE t1 IS 'table to store traffic data';

Add a comment to a column:

COMMENT ON COLUMN t1.v1 IS 'column for the duration of the trip';

Remove the comment on a table:

COMMENT ON table t1 IS NULL;

After a comment is added to a table or column, you can display it in these ways:

  1. Using the rw_description table:
SELECT * FROM rw_description;
------
 objoid | classoid | objsubid |             description
--------+----------+----------+-------------------------------------
   1001 |       41 |          | table to store traffic data
   1001 |       41 |        1 | column for the duration of the trip
   1001 |       41 |        2 |
   1001 |       41 |        0 |
  1. Using the SHOW COLUMNS or DESCRIBE command:
SHOW COLUMNS FROM t1;
DESCRIBE t1;