1COMMENT(7)               PostgreSQL 15.4 Documentation              COMMENT(7)
2
3
4

NAME

6       COMMENT - define or change the comment of an object
7

SYNOPSIS

9       COMMENT ON
10       {
11         ACCESS METHOD object_name |
12         AGGREGATE aggregate_name ( aggregate_signature ) |
13         CAST (source_type AS target_type) |
14         COLLATION object_name |
15         COLUMN relation_name.column_name |
16         CONSTRAINT constraint_name ON table_name |
17         CONSTRAINT constraint_name ON DOMAIN domain_name |
18         CONVERSION object_name |
19         DATABASE object_name |
20         DOMAIN object_name |
21         EXTENSION object_name |
22         EVENT TRIGGER object_name |
23         FOREIGN DATA WRAPPER object_name |
24         FOREIGN TABLE object_name |
25         FUNCTION function_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |
26         INDEX object_name |
27         LARGE OBJECT large_object_oid |
28         MATERIALIZED VIEW object_name |
29         OPERATOR operator_name (left_type, right_type) |
30         OPERATOR CLASS object_name USING index_method |
31         OPERATOR FAMILY object_name USING index_method |
32         POLICY policy_name ON table_name |
33         [ PROCEDURAL ] LANGUAGE object_name |
34         PROCEDURE procedure_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |
35         PUBLICATION object_name |
36         ROLE object_name |
37         ROUTINE routine_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |
38         RULE rule_name ON table_name |
39         SCHEMA object_name |
40         SEQUENCE object_name |
41         SERVER object_name |
42         STATISTICS object_name |
43         SUBSCRIPTION object_name |
44         TABLE object_name |
45         TABLESPACE object_name |
46         TEXT SEARCH CONFIGURATION object_name |
47         TEXT SEARCH DICTIONARY object_name |
48         TEXT SEARCH PARSER object_name |
49         TEXT SEARCH TEMPLATE object_name |
50         TRANSFORM FOR type_name LANGUAGE lang_name |
51         TRIGGER trigger_name ON table_name |
52         TYPE object_name |
53         VIEW object_name
54       } IS { string_literal | NULL }
55
56       where aggregate_signature is:
57
58       * |
59       [ argmode ] [ argname ] argtype [ , ... ] |
60       [ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]
61

DESCRIPTION

63       COMMENT stores a comment about a database object.
64
65       Only one comment string is stored for each object, so to modify a
66       comment, issue a new COMMENT command for the same object. To remove a
67       comment, write NULL in place of the text string. Comments are
68       automatically dropped when their object is dropped.
69
70       A SHARE UPDATE EXCLUSIVE lock is acquired on the object to be
71       commented.
72
73       For most kinds of object, only the object's owner can set the comment.
74       Roles don't have owners, so the rule for COMMENT ON ROLE is that you
75       must be superuser to comment on a superuser role, or have the
76       CREATEROLE privilege to comment on non-superuser roles. Likewise,
77       access methods don't have owners either; you must be superuser to
78       comment on an access method. Of course, a superuser can comment on
79       anything.
80
81       Comments can be viewed using psql's \d family of commands. Other user
82       interfaces to retrieve comments can be built atop the same built-in
83       functions that psql uses, namely obj_description, col_description, and
84       shobj_description (see Table 9.77).
85

PARAMETERS

87       object_name
88       relation_name.column_name
89       aggregate_name
90       constraint_name
91       function_name
92       operator_name
93       policy_name
94       procedure_name
95       routine_name
96       rule_name
97       trigger_name
98           The name of the object to be commented. Names of objects that
99           reside in schemas (tables, functions, etc.) can be
100           schema-qualified. When commenting on a column, relation_name must
101           refer to a table, view, composite type, or foreign table.
102
103       table_name
104       domain_name
105           When creating a comment on a constraint, a trigger, a rule or a
106           policy these parameters specify the name of the table or domain on
107           which that object is defined.
108
109       source_type
110           The name of the source data type of the cast.
111
112       target_type
113           The name of the target data type of the cast.
114
115       argmode
116           The mode of a function, procedure, or aggregate argument: IN, OUT,
117           INOUT, or VARIADIC. If omitted, the default is IN. Note that
118           COMMENT does not actually pay any attention to OUT arguments, since
119           only the input arguments are needed to determine the function's
120           identity. So it is sufficient to list the IN, INOUT, and VARIADIC
121           arguments.
122
123       argname
124           The name of a function, procedure, or aggregate argument. Note that
125           COMMENT does not actually pay any attention to argument names,
126           since only the argument data types are needed to determine the
127           function's identity.
128
129       argtype
130           The data type of a function, procedure, or aggregate argument.
131
132       large_object_oid
133           The OID of the large object.
134
135       left_type
136       right_type
137           The data type(s) of the operator's arguments (optionally
138           schema-qualified). Write NONE for the missing argument of a prefix
139           operator.
140
141       PROCEDURAL
142           This is a noise word.
143
144       type_name
145           The name of the data type of the transform.
146
147       lang_name
148           The name of the language of the transform.
149
150       string_literal
151           The new comment contents, written as a string literal.
152
153       NULL
154           Write NULL to drop the comment.
155

NOTES

157       There is presently no security mechanism for viewing comments: any user
158       connected to a database can see all the comments for objects in that
159       database. For shared objects such as databases, roles, and tablespaces,
160       comments are stored globally so any user connected to any database in
161       the cluster can see all the comments for shared objects. Therefore,
162       don't put security-critical information in comments.
163

EXAMPLES

165       Attach a comment to the table mytable:
166
167           COMMENT ON TABLE mytable IS 'This is my table.';
168
169       Remove it again:
170
171           COMMENT ON TABLE mytable IS NULL;
172
173       Some more examples:
174
175           COMMENT ON ACCESS METHOD gin IS 'GIN index access method';
176           COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance';
177           COMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';
178           COMMENT ON COLLATION "fr_CA" IS 'Canadian French';
179           COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
180           COMMENT ON CONVERSION my_conv IS 'Conversion to UTF8';
181           COMMENT ON CONSTRAINT bar_col_cons ON bar IS 'Constrains column col';
182           COMMENT ON CONSTRAINT dom_col_constr ON DOMAIN dom IS 'Constrains col of domain';
183           COMMENT ON DATABASE my_database IS 'Development Database';
184           COMMENT ON DOMAIN my_domain IS 'Email Address Domain';
185           COMMENT ON EVENT TRIGGER abort_ddl IS 'Aborts all DDL commands';
186           COMMENT ON EXTENSION hstore IS 'implements the hstore data type';
187           COMMENT ON FOREIGN DATA WRAPPER mywrapper IS 'my foreign data wrapper';
188           COMMENT ON FOREIGN TABLE my_foreign_table IS 'Employee Information in other database';
189           COMMENT ON FUNCTION my_function (timestamp) IS 'Returns Roman Numeral';
190           COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee ID';
191           COMMENT ON LANGUAGE plpython IS 'Python support for stored procedures';
192           COMMENT ON LARGE OBJECT 346344 IS 'Planning document';
193           COMMENT ON MATERIALIZED VIEW my_matview IS 'Summary of order history';
194           COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';
195           COMMENT ON OPERATOR - (NONE, integer) IS 'Unary minus';
196           COMMENT ON OPERATOR CLASS int4ops USING btree IS '4 byte integer operators for btrees';
197           COMMENT ON OPERATOR FAMILY integer_ops USING btree IS 'all integer operators for btrees';
198           COMMENT ON POLICY my_policy ON mytable IS 'Filter rows by users';
199           COMMENT ON PROCEDURE my_proc (integer, integer) IS 'Runs a report';
200           COMMENT ON PUBLICATION alltables IS 'Publishes all operations on all tables';
201           COMMENT ON ROLE my_role IS 'Administration group for finance tables';
202           COMMENT ON ROUTINE my_routine (integer, integer) IS 'Runs a routine (which is a function or procedure)';
203           COMMENT ON RULE my_rule ON my_table IS 'Logs updates of employee records';
204           COMMENT ON SCHEMA my_schema IS 'Departmental data';
205           COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';
206           COMMENT ON SERVER myserver IS 'my foreign server';
207           COMMENT ON STATISTICS my_statistics IS 'Improves planner row estimations';
208           COMMENT ON SUBSCRIPTION alltables IS 'Subscription for all operations on all tables';
209           COMMENT ON TABLE my_schema.my_table IS 'Employee Information';
210           COMMENT ON TABLESPACE my_tablespace IS 'Tablespace for indexes';
211           COMMENT ON TEXT SEARCH CONFIGURATION my_config IS 'Special word filtering';
212           COMMENT ON TEXT SEARCH DICTIONARY swedish IS 'Snowball stemmer for Swedish language';
213           COMMENT ON TEXT SEARCH PARSER my_parser IS 'Splits text into words';
214           COMMENT ON TEXT SEARCH TEMPLATE snowball IS 'Snowball stemmer';
215           COMMENT ON TRANSFORM FOR hstore LANGUAGE plpython3u IS 'Transform between hstore and Python dict';
216           COMMENT ON TRIGGER my_trigger ON my_table IS 'Used for RI';
217           COMMENT ON TYPE complex IS 'Complex number data type';
218           COMMENT ON VIEW my_view IS 'View of departmental costs';
219

COMPATIBILITY

221       There is no COMMENT command in the SQL standard.
222
223
224
225PostgreSQL 15.4                      2023                           COMMENT(7)
Impressum