Skip to main content
The COMMENT ON associates comments to , , , , or .
The “ statement performs a schema change. For more information about how online schema changes work in CockroachDB, see .

Required privileges

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

Synopsis

comment syntax diagram

Parameters

ParameterDescription
database_nameThe name of the on which you are commenting.
schema_nameThe name of the on which you are commenting.
type_nameThe name of the on which you are commenting.
table_nameThe name of the on which you are commenting.
column_nameThe name of the on which you are commenting.
table_index_nameThe name of the on which you are commenting.
comment_textThe comment () you are associating to the object. You can remove a comment by replacing the string with NULL.

Examples

Setup

To follow along, run to start a temporary, in-memory cluster with the sample dataset preloaded:

Add a comment to a database

To add a comment to a database:
To view database comments, use :

Add a comment to a table

To add a comment to a table:
To view table comments, use :
You can also view comments on a table with :

Add a comment to a column

To add a comment to a column:
To view column comments, use :

Add a comment to an index

Suppose we on the name column of the users table:
To add a comment to the index:
To view column comments, use :

Add a comment to a type

Issue a SQL statement to :
To view the type you just created, use :
To add a comment on the type, use a statement like the following:
To view all comments on types, make a against the system.comments table:

Remove a comment from a database

To remove a comment from a database:

Remove a comment from a type

To remove the comment from the type you created in the preceding example, add a NULL comment:

See also