COMMENT ON

New in v19.1: The COMMENT ON statement associates comments to databases, tables, or columns.

Tip:

Currently, COMMENT ON is best suited for use with database GUI navigation tools (e.g., dBeaver).

Required privileges

The user must have the CREATE privilege on the object they are commenting on.

Synopsis

COMMENTONDATABASEdatabase_nameTABLEtable_nameCOLUMNcolumn_pathIScomment_text

Parameters

ParameterDescription
database_nameThe name of the database you are commenting on.
table_nameThe name of the table you are commenting on.
column_nameThe name column you are commenting on.
comment_textThe comment (STRING) you are associating to the object.

Examples

Add a comment to a database

To add a comment to a database:

  1. > COMMENT ON DATABASE customers IS 'This is a sample comment';
  1. COMMENT ON DATABASE

To view database comments, use a database GUI navigation tool (e.g., dBeaver).

Add a comment to a table

To add a comment to a table:

  1. > COMMENT ON TABLE dogs IS 'This is a sample comment';
  1. COMMENT ON TABLE

To view table comments, use SHOW TABLES:

  1. > SHOW TABLES FROM customers WITH COMMENT;
  1. table_name | comment
  2. +------------+--------------------------+
  3. dogs | This is a sample comment
  4. (1 row)

Add a comment to a column

To add a comment to a column:

  1. > COMMENT ON COLUMN dogs.name IS 'This is a sample comment';
  1. COMMENT ON COLUMN

To view column comments, use a database GUI navigation tool (e.g., dBeaver).

See also

Was this page helpful?
YesNo