COMMENT ON

Description

The COMMENT ON statement sets or updates the comment on a database, a table, or one or more table columns. Setting a column comment to NULL removes it.

Syntax

COMMENT ON { DATABASE | SCHEMA | NAMESPACE } database_name IS comment

COMMENT ON TABLE table_name IS comment

COMMENT ON COLUMN table_name.column_name IS comment

COMMENT ON TABLE table_name COLUMN ( column_name IS comment [ , ... ] )

Parameters

Examples

-- Set a comment on a database
COMMENT ON DATABASE some_db IS 'This is a database';

-- Set a comment on a table
COMMENT ON TABLE some_db.some_table IS 'This is a table';

-- Set a comment on a single column
COMMENT ON COLUMN some_db.some_table.some_column IS 'This is a column';

-- Remove a column comment
COMMENT ON COLUMN some_db.some_table.some_column IS NULL;

-- Set comments on multiple columns, including a nested field
COMMENT ON TABLE some_db.some_table COLUMN (
  id IS 'The identifier',
  address.city IS 'The city part of the address'
);