COMMENT v15

Name

COMMENT Define or change the comment of an object.

Synopsis

COMMENT ON
{
  TABLE <table_name> |
  COLUMN <table_name.column_name>
} IS '<text>'

Description

COMMENT stores a comment about a database object. To modify a comment, issue a new COMMENT command for the same object. Only one comment string is stored for each object. To remove a comment, specify an empty string (two consecutive single quotes with no intervening space) for text. Comments are dropped when the object is dropped.

Parameters

table_name

The name of the table (optionally schema-qualified) to comment.

table_name.column_name

The name of a column (optionally schema-qualified) in table_name to comment.

text

The new comment.

Notes

There is currently no security mechanism for comments. Any user connected to a database can see all the comments for objects in that database, although only superusers can change comments for objects that they don’t own. Don't put security-critical information in a comment.

Examples

Attach a comment to the table 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';

Remove these comments:

COMMENT ON TABLE emp IS '';
COMMENT ON COLUMN emp.empno IS '';