Add or update a comment on a table or column.
Syntax
COMMENT ON
{
TABLE table_name |
COLUMN table_name.column_name
} IS 'text'Description
COMMENT ON stores a text comment on a database object. Each object holds at most one comment string — issuing a new COMMENT ON for the same object replaces the existing comment.
To delete a comment, set text to an empty string (two consecutive single quotation marks with no space between them: ''). Comments are also deleted automatically when the object is dropped.
Comments have no access controls. Any user connected to the database can read all comments on all objects. Do not store sensitive information in comments.
Parameters
| Parameter | Description |
|---|---|
table_name | The name of the table to comment on. Can be schema-qualified. |
table_name.column_name | The name of the column to comment on, in table.column format. The table name can be schema-qualified. |
text | The comment text. Pass an empty string ('') to delete an existing comment. |
Examples
Add comments
COMMENT ON TABLE emp IS 'Current employee information';
COMMENT ON COLUMN emp.empno IS 'Employee identification number';Delete comments
COMMENT ON TABLE emp IS '';
COMMENT ON COLUMN emp.empno IS '';View comments
View the comment and metadata for the emp table:
\dt+ empView comments on all columns in the emp table:
\d+ emp