RefLib

Reference library for AI

Back

postgresql_16:7.1.50.1 Description

PostgreSQL 16 > Reference > SQL Commands > COMMENT > Description

COMMENT stores, replaces, or removes the comment on a database object.

Only one comment string is stored for each object. Issuing a new COMMENT command for the same object replaces the existing comment. Specifying NULL or an empty string ('') removes the comment. Comments are automatically dropped when their object is dropped.

A SHARE UPDATE EXCLUSIVE lock is acquired on the object to be commented.

For most kinds of object, only the object's owner can set the comment. Roles don't have owners, so the rule for COMMENT ON ROLE is that you must be superuser to comment on a superuser role, or have the CREATEROLE privilege and have been granted ADMIN OPTION on the target role. Likewise, access methods don't have owners either; you must be superuser to comment on an access method. Of course, a superuser can comment on anything.

Comments can be viewed using psql's \d family of commands. Other user interfaces to retrieve comments can be built atop the same built-in functions that psql uses, namely obj_description, col_description, and shobj_description (see (see functions-info-comment-table)).

Back