COMMENT ONobjectnameIS'comment'COMMENT ON CONSTRAINT name ON table IS 'comment'
object
One of the following: COLUMN, DATABASE, ROLE, SCHEMA, SEQUENCE, TABLE, VIEW, KEY, PROCEDURE.
name
Database object name. Use table.name for column names, such as match.ftscore.
If a stored procedure has arguments, you must identify them in the procedure name. For example, either of the following names would work for a procedure addteam with one VARCHAR(30) argument:
addteam(varchar(30))addteam(namevarchar(30))
If a stored procedure does not have any arguments, specify its name with parentheses. For example:
droptable()
CONSTRAINT name ON table
For constraints, specify the table name as well as the constraint name.
'comment'
The text string that you want to save for the named object. Use null to remove an existing comment. Use a new COMMENT ON command to modify a comment. You can see the current comment for an object by using the appropriate backslash command with the plus sign, such as \d+ or \l+.
Do not put sensitive information in comments; any user can see comments on shared objects such as databases and roles. In general, only object owners and superusers can comment on objects. You must be a superuser to comment on a superuser role. You must have CREATEROLE privilege to comment on non-superuser roles.
premdb=# comment ontable awayteam is'Just a reference for atid in the match table';COMMENTpremdb=# comment on view matchview is'View of match table';COMMENTpremdb=# \d+ List of relationsSchema | Name | Type | Owner | Description--------+-----------+-------+---------+---------------------------------------------- public | awayteam | table | brumsby | Just a reference for atid in the match table public | hometeam | table | brumsby | public | match | table | brumsby | public | matchview | view | brumsby | View of match table public | season | table | brumsby | public | team | table | brumsby | (6rows)
COMMENT ON
Comment on a database object.
One of the following:
COLUMN
,DATABASE
,ROLE
,SCHEMA
,SEQUENCE
,TABLE
,VIEW
,KEY
,PROCEDURE
.Database object name. Use
table.name
for column names, such asmatch.ftscore
.If a stored procedure has arguments, you must identify them in the procedure name. For example, either of the following names would work for a procedure
addteam
with oneVARCHAR(30)
argument:If a stored procedure does not have any arguments, specify its name with parentheses. For example:
For constraints, specify the table name as well as the constraint name.
The text string that you want to save for the named object. Use
null
to remove an existing comment. Use a newCOMMENT ON
command to modify a comment. You can see the current comment for an object by using the appropriate backslash command with the plus sign, such as\d+
or\l+
.Do not put sensitive information in comments; any user can see comments on shared objects such as databases and roles. In general, only object owners and superusers can comment on objects. You must be a superuser to comment on a superuser role. You must have
CREATEROLE
privilege to comment on non-superuser roles.Examples
Comment on a table and a view:
Comment on a table column:
Comment on a stored procedure:
Comment on a primary key constraint for a table: