1COMMENT(7)               PostgreSQL 11.6 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 'text'
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       For most kinds of object, only the object's owner can set the comment.
71       Roles don't have owners, so the rule for COMMENT ON ROLE is that you
72       must be superuser to comment on a superuser role, or have the
73       CREATEROLE privilege to comment on non-superuser roles. Likewise,
74       access methods don't have owners either; you must be superuser to
75       comment on an access method. Of course, a superuser can comment on
76       anything.
77
78       Comments can be viewed using psql's \d family of commands. Other user
79       interfaces to retrieve comments can be built atop the same built-in
80       functions that psql uses, namely obj_description, col_description, and
81       shobj_description (see Table 9.68).
82

PARAMETERS

84       object_name
85       relation_name.column_name
86       aggregate_name
87       constraint_name
88       function_name
89       operator_name
90       policy_name
91       procedure_name
92       routine_name
93       rule_name
94       trigger_name
95           The name of the object to be commented. Names of tables,
96           aggregates, collations, conversions, domains, foreign tables,
97           functions, indexes, operators, operator classes, operator families,
98           procedures, routines, sequences, statistics, text search objects,
99           types, and views can be schema-qualified. When commenting on a
100           column, relation_name must refer to a table, view, composite type,
101           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           or postfix 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       text
151           The new comment, written as a string literal; or NULL to drop the
152           comment.
153

NOTES

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

EXAMPLES

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

COMPATIBILITY

215       There is no COMMENT command in the SQL standard.
216
217
218
219PostgreSQL 11.6                      2019                           COMMENT(7)
Impressum