Skip to main content
The COMMENT ON statement associates comments to databases, tables, columns, or indexes. The COMMENT ON statement performs a schema change. For more information about how online schema changes work in CockroachDB, see Online Schema Changes.

Required privileges

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

Synopsis

comment syntax diagram

Parameters

Examples

Setup

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

Add a comment to a database

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

Add a comment to a table

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

Add a comment to a column

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

Add a comment to an index

Suppose we create an index on the name column of the users table:
To add a comment to the index:
To view column comments, use SHOW INDEXES... WITH COMMENT:

Remove a comment from a database

To remove a comment from a database:

See also