1COMMENT(7)               PostgreSQL 10.7 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         PUBLICATION object_name |
35         ROLE object_name |
36         RULE rule_name ON table_name |
37         SCHEMA object_name |
38         SEQUENCE object_name |
39         SERVER object_name |
40         STATISTICS object_name |
41         SUBSCRIPTION object_name |
42         TABLE object_name |
43         TABLESPACE object_name |
44         TEXT SEARCH CONFIGURATION object_name |
45         TEXT SEARCH DICTIONARY object_name |
46         TEXT SEARCH PARSER object_name |
47         TEXT SEARCH TEMPLATE object_name |
48         TRANSFORM FOR type_name LANGUAGE lang_name |
49         TRIGGER trigger_name ON table_name |
50         TYPE object_name |
51         VIEW object_name
52       } IS 'text'
53
54       where aggregate_signature is:
55
56       * |
57       [ argmode ] [ argname ] argtype [ , ... ] |
58       [ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]
59

DESCRIPTION

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

PARAMETERS

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

NOTES

149       There is presently no security mechanism for viewing comments: any user
150       connected to a database can see all the comments for objects in that
151       database. For shared objects such as databases, roles, and tablespaces,
152       comments are stored globally so any user connected to any database in
153       the cluster can see all the comments for shared objects. Therefore,
154       don't put security-critical information in comments.
155

EXAMPLES

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

COMPATIBILITY

208       There is no COMMENT command in the SQL standard.
209
210
211
212PostgreSQL 10.7                      2019                           COMMENT(7)
Impressum