COMMENT - Amazon Redshift


Creates or changes a comment about a database object.


COMMENT ON { TABLE object_name | COLUMN object_name.column_name | CONSTRAINT constraint_name ON table_name | DATABASE object_name | VIEW object_name } IS 'text'



Name of the database object being commented on. You can add a comment to the following objects:


  • COLUMN (also takes a column_name).

  • CONSTRAINT (also takes a constraint_name and table_name).


  • VIEW

IS 'text''

The text of the comment that you want to apply to the specified object. Enclose the comment in single quotation marks.


Name of the column being commented on. Parameter of COLUMN. Follows a table specified in object_name.


Name of the constraint that is being commented on. Parameter of CONSTRAINT.


Name of a table containing the constraint. Parameter of CONSTRAINT.

arg1_type, arg2_type, ...

Data types of the arguments for a function. Parameter of FUNCTION.

Usage notes

Comments on databases may only be applied to the current database. A warning message is displayed if you attempt to comment on a different database. The same warning is displayed for comments on databases that don't exist.


The following example adds a descriptive comment to the EVENT table:

comment on table event is 'Contains listings of individual events.';

To view comments, query the PG_DESCRIPTION system catalog. The following example returns the description for the EVENT table.

select * from pg_catalog.pg_description where objoid = (select oid from pg_class where relname = 'event' and relnamespace = (select oid from pg_catalog.pg_namespace where nspname = 'public') ); objoid | classoid | objsubid | description -------+----------+----------+---------------------------------------- 116658 | 1259 | 0 | Contains listings of individual events.

The following example uses the psql \dd command to view the comments. Amazon Redshift doesn't support psql directly. You must run psql commands from the PostgreSQL psql client.


The \dd command returns comments only with the psql 8.x versions.

\dd event Object descriptions schema | name | object | description --------+-------+--------+----------------------------------------- public | event | table | Contains listings of individual events. (1 row)