COMMENT ON

PREVIEW This feature is in public preview. It is under active development and may have stability or performance issues. It isn't subject to our backwards compatibility guarantees.

COMMENT ON ... adds or updates the comment of an object.

Syntax

COMMENT ON CLUSTER CLUSTER REPLICA COLUMN CONNECTION DATABASE FUNCTION INDEX MATERIALIZED VIEW ROLE SCHEMA SECRET SINK SOURCE TABLE TYPE VIEW object_name IS string_literal NULL

Details

COMMENT ON stores a comment about an object in the database. Each object can only have one comment associated with it, so successive calls of COMMENT ON to a single object will overwrite the previous comment.

To read the comment on an object you need to query the mz_internal.mz_comments catalog table.

Privileges

To comment on an object, the current role must be the owner of that object. Roles themselves do not have owners, so to comment on a role object you must have the CREATEROLE privilege. For more information on ownership and privileges, see Role-based access control.

Examples

--- Add comments.
COMMENT ON TABLE foo IS 'this table is important';
COMMENT ON COLUMN foo.x IS 'holds all of the important data';

--- Update a comment.
COMMENT ON TABLE foo IS 'holds non-important data';

--- Remove a comment.
COMMENT ON TABLE foo IS NULL;

--- Read comments.
SELECT * FROM mz_internal.mz_comments;
Back to top ↑