4 COMMENT — define or change the comment of an object
10 ACCESS METHOD object_name |
11 AGGREGATE aggregate_name ( aggregate_signature ) |
12 CAST (source_type AS target_type) |
13 COLLATION object_name |
14 COLUMN relation_name.column_name |
15 CONSTRAINT constraint_name ON table_name |
16 CONSTRAINT constraint_name ON DOMAIN domain_name |
17 CONVERSION object_name |
18 DATABASE object_name |
20 EXTENSION object_name |
21 EVENT TRIGGER object_name |
22 FOREIGN DATA WRAPPER object_name |
23 FOREIGN TABLE object_name |
24 FUNCTION function_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |
26 LARGE OBJECT large_object_oid |
27 MATERIALIZED VIEW object_name |
28 OPERATOR operator_name (left_type, right_type) |
29 OPERATOR CLASS object_name USING index_method |
30 OPERATOR FAMILY object_name USING index_method |
31 POLICY policy_name ON table_name |
32 [ PROCEDURAL ] LANGUAGE object_name |
33 PROCEDURE procedure_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |
34 PUBLICATION object_name |
36 ROUTINE routine_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |
37 RULE rule_name ON table_name |
39 SEQUENCE object_name |
41 STATISTICS object_name |
42 SUBSCRIPTION object_name |
44 TABLESPACE object_name |
45 TEXT SEARCH CONFIGURATION object_name |
46 TEXT SEARCH DICTIONARY object_name |
47 TEXT SEARCH PARSER object_name |
48 TEXT SEARCH TEMPLATE object_name |
49 TRANSFORM FOR type_name LANGUAGE lang_name |
50 TRIGGER trigger_name ON table_name |
53 } IS { string_literal | NULL }
55 where aggregate_signature is:
58 [ argmode ] [ argname ] argtype [ , ... ] |
59 [ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] a
64 COMMENT stores a comment about a database object.
66 Only one comment string is stored for each object, so to modify a
67 comment, issue a new COMMENT command for the same object. To remove a
68 comment, write NULL in place of the text string. Comments are
69 automatically dropped when their object is dropped.
71 A SHARE UPDATE EXCLUSIVE lock is acquired on the object to be
74 For most kinds of object, only the object's owner can set the comment.
75 Roles don't have owners, so the rule for COMMENT ON ROLE is that you
76 must be superuser to comment on a superuser role, or have the
77 CREATEROLE privilege and have been granted ADMIN OPTION on the target
78 role. Likewise, access methods don't have owners either; you must be
79 superuser to comment on an access method. Of course, a superuser can
82 Comments can be viewed using psql's \d family of commands. Other user
83 interfaces to retrieve comments can be built atop the same built-in
84 functions that psql uses, namely obj_description, col_description, and
85 shobj_description (see Table 9.82).
90 relation_name.column_name
100 The name of the object to be commented. Names of objects that
101 reside in schemas (tables, functions, etc.) can be
102 schema-qualified. When commenting on a column, relation_name
103 must refer to a table, view, composite type, or foreign table.
107 When creating a comment on a constraint, a trigger, a rule or a
108 policy these parameters specify the name of the table or domain
109 on which that object is defined.
112 The name of the source data type of the cast.
115 The name of the target data type of the cast.
118 The mode of a function, procedure, or aggregate argument: IN,
119 OUT, INOUT, or VARIADIC. If omitted, the default is IN. Note
120 that COMMENT does not actually pay any attention to OUT
121 arguments, since only the input arguments are needed to
122 determine the function's identity. So it is sufficient to list
123 the IN, INOUT, and VARIADIC arguments.
126 The name of a function, procedure, or aggregate argument. Note
127 that COMMENT does not actually pay any attention to argument
128 names, since only the argument data types are needed to
129 determine the function's identity.
132 The data type of a function, procedure, or aggregate argument.
135 The OID of the large object.
139 The data type(s) of the operator's arguments (optionally
140 schema-qualified). Write NONE for the missing argument of a
144 This is a noise word.
147 The name of the data type of the transform.
150 The name of the language of the transform.
153 The new comment contents, written as a string literal.
156 Write NULL to drop the comment.
160 There is presently no security mechanism for viewing comments: any user
161 connected to a database can see all the comments for objects in that
162 database. For shared objects such as databases, roles, and tablespaces,
163 comments are stored globally so any user connected to any database in
164 the cluster can see all the comments for shared objects. Therefore,
165 don't put security-critical information in comments.
169 Attach a comment to the table mytable:
170 COMMENT ON TABLE mytable IS 'This is my table.';
173 COMMENT ON TABLE mytable IS NULL;
176 COMMENT ON ACCESS METHOD gin IS 'GIN index access method';
177 COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample varianc
179 COMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';
180 COMMENT ON COLLATION "fr_CA" IS 'Canadian French';
181 COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
182 COMMENT ON CONVERSION my_conv IS 'Conversion to UTF8';
183 COMMENT ON CONSTRAINT bar_col_cons ON bar IS 'Constrains column col';
184 COMMENT ON CONSTRAINT dom_col_constr ON DOMAIN dom IS 'Constrains col of domain'
186 COMMENT ON DATABASE my_database IS 'Development Database';
187 COMMENT ON DOMAIN my_domain IS 'Email Address Domain';
188 COMMENT ON EVENT TRIGGER abort_ddl IS 'Aborts all DDL commands';
189 COMMENT ON EXTENSION hstore IS 'implements the hstore data type';
190 COMMENT ON FOREIGN DATA WRAPPER mywrapper IS 'my foreign data wrapper';
191 COMMENT ON FOREIGN TABLE my_foreign_table IS 'Employee Information in other data
193 COMMENT ON FUNCTION my_function (timestamp) IS 'Returns Roman Numeral';
194 COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee ID';
195 COMMENT ON LANGUAGE plpython IS 'Python support for stored procedures';
196 COMMENT ON LARGE OBJECT 346344 IS 'Planning document';
197 COMMENT ON MATERIALIZED VIEW my_matview IS 'Summary of order history';
198 COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';
199 COMMENT ON OPERATOR - (NONE, integer) IS 'Unary minus';
200 COMMENT ON OPERATOR CLASS int4ops USING btree IS '4 byte integer operators for b
202 COMMENT ON OPERATOR FAMILY integer_ops USING btree IS 'all integer operators for
204 COMMENT ON POLICY my_policy ON mytable IS 'Filter rows by users';
205 COMMENT ON PROCEDURE my_proc (integer, integer) IS 'Runs a report';
206 COMMENT ON PUBLICATION alltables IS 'Publishes all operations on all tables';
207 COMMENT ON ROLE my_role IS 'Administration group for finance tables';
208 COMMENT ON ROUTINE my_routine (integer, integer) IS 'Runs a routine (which is a
209 function or procedure)';
210 COMMENT ON RULE my_rule ON my_table IS 'Logs updates of employee records';
211 COMMENT ON SCHEMA my_schema IS 'Departmental data';
212 COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';
213 COMMENT ON SERVER myserver IS 'my foreign server';
214 COMMENT ON STATISTICS my_statistics IS 'Improves planner row estimations';
215 COMMENT ON SUBSCRIPTION alltables IS 'Subscription for all operations on all tab
217 COMMENT ON TABLE my_schema.my_table IS 'Employee Information';
218 COMMENT ON TABLESPACE my_tablespace IS 'Tablespace for indexes';
219 COMMENT ON TEXT SEARCH CONFIGURATION my_config IS 'Special word filtering';
220 COMMENT ON TEXT SEARCH DICTIONARY swedish IS 'Snowball stemmer for Swedish langu
222 COMMENT ON TEXT SEARCH PARSER my_parser IS 'Splits text into words';
223 COMMENT ON TEXT SEARCH TEMPLATE snowball IS 'Snowball stemmer';
224 COMMENT ON TRANSFORM FOR hstore LANGUAGE plpython3u IS 'Transform between hstore
226 COMMENT ON TRIGGER my_trigger ON my_table IS 'Used for RI';
227 COMMENT ON TYPE complex IS 'Complex number data type';
228 COMMENT ON VIEW my_view IS 'View of departmental costs';
232 There is no COMMENT command in the SQL standard.