COMMENT ON

On this page Carat arrow pointing down
Warning:
CockroachDB v19.1 is no longer supported. For more details, see the Release Support Policy.

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

COMMENT ON DATABASE database_name TABLE table_name COLUMN column_path IS comment_text

Parameters

Parameter Description
database_name The name of the database you are commenting on.
table_name The name of the table you are commenting on.
column_name The name of the column you are commenting on.
comment_text The comment (STRING) you are associating to the object.

Examples

Add a comment to a database

To add a comment to a database:

icon/buttons/copy
> COMMENT ON DATABASE customers IS 'This is a sample comment';
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:

icon/buttons/copy
> COMMENT ON TABLE dogs IS 'This is a sample comment';
COMMENT ON TABLE

To view table comments, use SHOW TABLES:

icon/buttons/copy
> SHOW TABLES FROM customers WITH COMMENT;
  table_name |         comment
+------------+--------------------------+
  dogs       | This is a sample comment
(1 row)

Add a comment to a column

To add a comment to a column:

icon/buttons/copy
> COMMENT ON COLUMN dogs.name IS 'This is a sample comment';
COMMENT ON COLUMN

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

See also


Yes No
On this page

Yes No