Defines or modifies the comment of an object.


  TABLE table_name |
  COLUMN table_name.column_name
} IS 'text'


You can use the COMMENT command to store comments about database objects. To modify a comment of an object, you need to issue a new COMMENT command for the object. Only one comment string can be stored for each object. To delete a comment, specify an empty string (two consecutive single quotation marks with no space) for the text parameter. A comment is automatically deleted when the object is deleted.

Note Currently, no security mechanism is provided for comments. Any user who connects to the database can view all comments of the objects in the database. Do not include important security information in comments.


Parameter Description
table_name The name of the table to be commented. The table name can be schema-qualified.
table_name.column_name The name of the column to be commented in the table. The table name can be schema-qualified.
text The new comment.


Attach a comment to a table named emp:

COMMENT ON TABLE emp IS 'Current employee information';

Attach a comment to the empno column of the emp table:

COMMENT ON COLUMN emp.empno IS 'Employee identification number';

Delete the comments:

COMMENT ON COLUMN emp.empno IS '';

View comments for emp table:

\dt+ emp;

View comments for columns in the emp table:

\d+ emp;