COMMENT

Name

COMMENT  --  Adds a comment to an object within the database.

Synopsis

COMMENT ON
[
  [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ]
  object_name |
  COLUMN table_name.column_name|
  AGGREGATE agg_name agg_type|
  FUNCTION func_name (arg1, arg2, ...)|
  OPERATOR op (leftoperand_type rightoperand_type) |
  TRIGGER trigger_name ON table_name
] IS 'text'
  

Parameters

object_name, table_name, column_name, agg_name, func_name, op, trigger_name

This parameter takes the name of the object you are adding a comment to.

text

Use this parameter to enter the text of the comment to add.

Results

COMMENT

This message is displayed if the object is successfully commented.

Description

The COMMENT is a PostgreSQL-specific command that allows you to add comments to most objects within a database, including the database itself. Comments can be retrieved by using the following commands from within the psql client: \dd, \d+, or \l+. You can remove a comment by setting its text to NULL.

NoteNote
 

A comment that has been made on an object will be removed when that object is removed from the system.

Examples

The following example adds a comment to the customer table.

COMMENT ON TABLE customer IS 'This is the customer table.';

The next example deletes the previously added comment from the customer table.

COMMENT ON TABLE customer IS NULL;