3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "COMMENT" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 COMMENT \- define or change the comment of an object
37 ACCESS METHOD \fIobject_name\fR |
38 AGGREGATE \fIaggregate_name\fR ( \fIaggregate_signature\fR ) |
39 CAST (\fIsource_type\fR AS \fItarget_type\fR) |
40 COLLATION \fIobject_name\fR |
41 COLUMN \fIrelation_name\fR\&.\fIcolumn_name\fR |
42 CONSTRAINT \fIconstraint_name\fR ON \fItable_name\fR |
43 CONSTRAINT \fIconstraint_name\fR ON DOMAIN \fIdomain_name\fR |
44 CONVERSION \fIobject_name\fR |
45 DATABASE \fIobject_name\fR |
46 DOMAIN \fIobject_name\fR |
47 EXTENSION \fIobject_name\fR |
48 EVENT TRIGGER \fIobject_name\fR |
49 FOREIGN DATA WRAPPER \fIobject_name\fR |
50 FOREIGN TABLE \fIobject_name\fR |
51 FUNCTION \fIfunction_name\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ] |
52 INDEX \fIobject_name\fR |
53 LARGE OBJECT \fIlarge_object_oid\fR |
54 MATERIALIZED VIEW \fIobject_name\fR |
55 OPERATOR \fIoperator_name\fR (\fIleft_type\fR, \fIright_type\fR) |
56 OPERATOR CLASS \fIobject_name\fR USING \fIindex_method\fR |
57 OPERATOR FAMILY \fIobject_name\fR USING \fIindex_method\fR |
58 POLICY \fIpolicy_name\fR ON \fItable_name\fR |
59 [ PROCEDURAL ] LANGUAGE \fIobject_name\fR |
60 PROCEDURE \fIprocedure_name\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ] |
61 PUBLICATION \fIobject_name\fR |
62 ROLE \fIobject_name\fR |
63 ROUTINE \fIroutine_name\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ] |
64 RULE \fIrule_name\fR ON \fItable_name\fR |
65 SCHEMA \fIobject_name\fR |
66 SEQUENCE \fIobject_name\fR |
67 SERVER \fIobject_name\fR |
68 STATISTICS \fIobject_name\fR |
69 SUBSCRIPTION \fIobject_name\fR |
70 TABLE \fIobject_name\fR |
71 TABLESPACE \fIobject_name\fR |
72 TEXT SEARCH CONFIGURATION \fIobject_name\fR |
73 TEXT SEARCH DICTIONARY \fIobject_name\fR |
74 TEXT SEARCH PARSER \fIobject_name\fR |
75 TEXT SEARCH TEMPLATE \fIobject_name\fR |
76 TRANSFORM FOR \fItype_name\fR LANGUAGE \fIlang_name\fR |
77 TRIGGER \fItrigger_name\fR ON \fItable_name\fR |
78 TYPE \fIobject_name\fR |
79 VIEW \fIobject_name\fR
80 } IS { \fIstring_literal\fR | NULL }
82 where \fIaggregate_signature\fR is:
85 [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] |
86 [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] ] ORDER BY [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ]
91 stores a comment about a database object\&.
93 Only one comment string is stored for each object, so to modify a comment, issue a new
95 command for the same object\&. To remove a comment, write
97 in place of the text string\&. Comments are automatically dropped when their object is dropped\&.
100 SHARE UPDATE EXCLUSIVE
101 lock is acquired on the object to be commented\&.
103 For most kinds of object, only the object\*(Aqs owner can set the comment\&. Roles don\*(Aqt have owners, so the rule for
105 is that you must be superuser to comment on a superuser role, or have the
107 privilege and have been granted
109 on the target role\&. Likewise, access methods don\*(Aqt have owners either; you must be superuser to comment on an access method\&. Of course, a superuser can comment on anything\&.
111 Comments can be viewed using
114 family of commands\&. Other user interfaces to retrieve comments can be built atop the same built\-in functions that
117 \fBobj_description\fR,
118 \fBcol_description\fR, and
119 \fBshobj_description\fR
126 \fIrelation_name\fR\&.\fIcolumn_name\fR
130 \fIconstraint_name\fR
146 The name of the object to be commented\&. Names of objects that reside in schemas (tables, functions, etc\&.) can be schema\-qualified\&. When commenting on a column,
148 must refer to a table, view, composite type, or foreign table\&.
155 When creating a comment on a constraint, a trigger, a rule or a policy these parameters specify the name of the table or domain on which that object is defined\&.
160 The name of the source data type of the cast\&.
165 The name of the target data type of the cast\&.
170 The mode of a function, procedure, or aggregate argument:
174 VARIADIC\&. If omitted, the default is
177 does not actually pay any attention to
179 arguments, since only the input arguments are needed to determine the function\*(Aqs identity\&. So it is sufficient to list the
188 The name of a function, procedure, or aggregate argument\&. Note that
190 does not actually pay any attention to argument names, since only the argument data types are needed to determine the function\*(Aqs identity\&.
195 The data type of a function, procedure, or aggregate argument\&.
198 \fIlarge_object_oid\fR
200 The OID of the large object\&.
207 The data type(s) of the operator\*(Aqs arguments (optionally schema\-qualified)\&. Write
209 for the missing argument of a prefix operator\&.
214 This is a noise word\&.
219 The name of the data type of the transform\&.
224 The name of the language of the transform\&.
229 The new comment contents, written as a string literal\&.
236 to drop the comment\&.
240 There is presently no security mechanism for viewing comments: any user connected to a database can see all the comments for objects in that database\&. For shared objects such as databases, roles, and tablespaces, comments are stored globally so any user connected to any database in the cluster can see all the comments for shared objects\&. Therefore, don\*(Aqt put security\-critical information in comments\&.
243 Attach a comment to the table
250 COMMENT ON TABLE mytable IS \*(AqThis is my table\&.\*(Aq;
262 COMMENT ON TABLE mytable IS NULL;
274 COMMENT ON ACCESS METHOD gin IS \*(AqGIN index access method\*(Aq;
275 COMMENT ON AGGREGATE my_aggregate (double precision) IS \*(AqComputes sample variance\*(Aq;
276 COMMENT ON CAST (text AS int4) IS \*(AqAllow casts from text to int4\*(Aq;
277 COMMENT ON COLLATION "fr_CA" IS \*(AqCanadian French\*(Aq;
278 COMMENT ON COLUMN my_table\&.my_column IS \*(AqEmployee ID number\*(Aq;
279 COMMENT ON CONVERSION my_conv IS \*(AqConversion to UTF8\*(Aq;
280 COMMENT ON CONSTRAINT bar_col_cons ON bar IS \*(AqConstrains column col\*(Aq;
281 COMMENT ON CONSTRAINT dom_col_constr ON DOMAIN dom IS \*(AqConstrains col of domain\*(Aq;
282 COMMENT ON DATABASE my_database IS \*(AqDevelopment Database\*(Aq;
283 COMMENT ON DOMAIN my_domain IS \*(AqEmail Address Domain\*(Aq;
284 COMMENT ON EVENT TRIGGER abort_ddl IS \*(AqAborts all DDL commands\*(Aq;
285 COMMENT ON EXTENSION hstore IS \*(Aqimplements the hstore data type\*(Aq;
286 COMMENT ON FOREIGN DATA WRAPPER mywrapper IS \*(Aqmy foreign data wrapper\*(Aq;
287 COMMENT ON FOREIGN TABLE my_foreign_table IS \*(AqEmployee Information in other database\*(Aq;
288 COMMENT ON FUNCTION my_function (timestamp) IS \*(AqReturns Roman Numeral\*(Aq;
289 COMMENT ON INDEX my_index IS \*(AqEnforces uniqueness on employee ID\*(Aq;
290 COMMENT ON LANGUAGE plpython IS \*(AqPython support for stored procedures\*(Aq;
291 COMMENT ON LARGE OBJECT 346344 IS \*(AqPlanning document\*(Aq;
292 COMMENT ON MATERIALIZED VIEW my_matview IS \*(AqSummary of order history\*(Aq;
293 COMMENT ON OPERATOR ^ (text, text) IS \*(AqPerforms intersection of two texts\*(Aq;
294 COMMENT ON OPERATOR \- (NONE, integer) IS \*(AqUnary minus\*(Aq;
295 COMMENT ON OPERATOR CLASS int4ops USING btree IS \*(Aq4 byte integer operators for btrees\*(Aq;
296 COMMENT ON OPERATOR FAMILY integer_ops USING btree IS \*(Aqall integer operators for btrees\*(Aq;
297 COMMENT ON POLICY my_policy ON mytable IS \*(AqFilter rows by users\*(Aq;
298 COMMENT ON PROCEDURE my_proc (integer, integer) IS \*(AqRuns a report\*(Aq;
299 COMMENT ON PUBLICATION alltables IS \*(AqPublishes all operations on all tables\*(Aq;
300 COMMENT ON ROLE my_role IS \*(AqAdministration group for finance tables\*(Aq;
301 COMMENT ON ROUTINE my_routine (integer, integer) IS \*(AqRuns a routine (which is a function or procedure)\*(Aq;
302 COMMENT ON RULE my_rule ON my_table IS \*(AqLogs updates of employee records\*(Aq;
303 COMMENT ON SCHEMA my_schema IS \*(AqDepartmental data\*(Aq;
304 COMMENT ON SEQUENCE my_sequence IS \*(AqUsed to generate primary keys\*(Aq;
305 COMMENT ON SERVER myserver IS \*(Aqmy foreign server\*(Aq;
306 COMMENT ON STATISTICS my_statistics IS \*(AqImproves planner row estimations\*(Aq;
307 COMMENT ON SUBSCRIPTION alltables IS \*(AqSubscription for all operations on all tables\*(Aq;
308 COMMENT ON TABLE my_schema\&.my_table IS \*(AqEmployee Information\*(Aq;
309 COMMENT ON TABLESPACE my_tablespace IS \*(AqTablespace for indexes\*(Aq;
310 COMMENT ON TEXT SEARCH CONFIGURATION my_config IS \*(AqSpecial word filtering\*(Aq;
311 COMMENT ON TEXT SEARCH DICTIONARY swedish IS \*(AqSnowball stemmer for Swedish language\*(Aq;
312 COMMENT ON TEXT SEARCH PARSER my_parser IS \*(AqSplits text into words\*(Aq;
313 COMMENT ON TEXT SEARCH TEMPLATE snowball IS \*(AqSnowball stemmer\*(Aq;
314 COMMENT ON TRANSFORM FOR hstore LANGUAGE plpython3u IS \*(AqTransform between hstore and Python dict\*(Aq;
315 COMMENT ON TRIGGER my_trigger ON my_table IS \*(AqUsed for RI\*(Aq;
316 COMMENT ON TYPE complex IS \*(AqComplex number data type\*(Aq;
317 COMMENT ON VIEW my_view IS \*(AqView of departmental costs\*(Aq;
326 command in the SQL standard\&.