On this page
New in v19.1: The COMMENT ON
statement associates comments to databases, tables, or columns.
Tip:
Currently, COMMENT ON
is best suited for use with database GUI navigation tools (e.g., dBeaver).
Required privileges
The user must have the CREATE
privilege on the object they are commenting on.
Synopsis
Parameters
Parameter | Description |
---|---|
database_name |
The name of the database you are commenting on. |
table_name |
The name of the table you are commenting on. |
column_name |
The name of the column you are commenting on. |
comment_text |
The comment (STRING ) you are associating to the object. |
Examples
Add a comment to a database
To add a comment to a database:
> COMMENT ON DATABASE customers IS 'This is a sample comment';
COMMENT ON DATABASE
To view database comments, use a database GUI navigation tool (e.g., dBeaver).
Add a comment to a table
To add a comment to a table:
> COMMENT ON TABLE dogs IS 'This is a sample comment';
COMMENT ON TABLE
To view table comments, use SHOW TABLES
:
> SHOW TABLES FROM customers WITH COMMENT;
table_name | comment
+------------+--------------------------+
dogs | This is a sample comment
(1 row)
Add a comment to a column
To add a comment to a column:
> COMMENT ON COLUMN dogs.name IS 'This is a sample comment';
COMMENT ON COLUMN
To view column comments, use a database GUI navigation tool (e.g., dBeaver).