2 $PostgreSQL: pgsql/doc/src/sgml/ref/comment.sgml,v 1.26 2005/01/04 00:39:53 tgl Exp $
3 PostgreSQL documentation
6 <refentry id="SQL-COMMENT">
8 <refentrytitle id="SQL-COMMENT-TITLE">COMMENT</refentrytitle>
9 <refmiscinfo>SQL - Language Statements</refmiscinfo>
13 <refname>COMMENT</refname>
14 <refpurpose>define or change the comment of an object</refpurpose>
17 <indexterm zone="sql-comment">
18 <primary>COMMENT</primary>
25 TABLE <replaceable class="PARAMETER">object_name</replaceable> |
26 COLUMN <replaceable class="PARAMETER">table_name</replaceable>.<replaceable class="PARAMETER">column_name</replaceable> |
27 AGGREGATE <replaceable class="PARAMETER">agg_name</replaceable> (<replaceable class="PARAMETER">agg_type</replaceable>) |
28 CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</replaceable>) |
29 CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> |
30 CONVERSION <replaceable class="PARAMETER">object_name</replaceable> |
31 DATABASE <replaceable class="PARAMETER">object_name</replaceable> |
32 DOMAIN <replaceable class="PARAMETER">object_name</replaceable> |
33 FUNCTION <replaceable class="PARAMETER">func_name</replaceable> (<replaceable class="PARAMETER">arg1_type</replaceable>, <replaceable class="PARAMETER">arg2_type</replaceable>, ...) |
34 INDEX <replaceable class="PARAMETER">object_name</replaceable> |
35 LARGE OBJECT <replaceable class="PARAMETER">large_object_oid</replaceable> |
36 OPERATOR <replaceable class="PARAMETER">op</replaceable> (<replaceable class="PARAMETER">leftoperand_type</replaceable>, <replaceable class="PARAMETER">rightoperand_type</replaceable>) |
37 OPERATOR CLASS <replaceable class="PARAMETER">object_name</replaceable> USING <replaceable class="parameter">index_method</replaceable> |
38 [ PROCEDURAL ] LANGUAGE <replaceable class="PARAMETER">object_name</replaceable> |
39 RULE <replaceable class="PARAMETER">rule_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> |
40 SCHEMA <replaceable class="PARAMETER">object_name</replaceable> |
41 SEQUENCE <replaceable class="PARAMETER">object_name</replaceable> |
42 TRIGGER <replaceable class="PARAMETER">trigger_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> |
43 TYPE <replaceable class="PARAMETER">object_name</replaceable> |
44 VIEW <replaceable class="PARAMETER">object_name</replaceable>
45 } IS <replaceable class="PARAMETER">'text'</replaceable>
50 <title>Description</title>
53 <command>COMMENT</command> stores a comment about a database object.
57 To modify a comment, issue a new <command>COMMENT</> command for the
58 same object. Only one comment string is stored for each object.
59 To remove a comment, write <literal>NULL</literal> in place of the text
61 Comments are automatically dropped when the object is dropped.
66 easily retrieved with the <application>psql</application> commands
67 <command>\dd</command>, <command>\d+</command>, and <command>\l+</command>.
68 Other user interfaces to retrieve comments can be built atop
69 the same built-in functions that <application>psql</application> uses, namely
70 <function>obj_description</> and <function>col_description</>
71 (see <xref linkend="functions-info-comment-table">).
76 <title>Parameters</title>
80 <term><replaceable class="parameter">object_name</replaceable></term>
81 <term><replaceable class="parameter">table_name.column_name</replaceable></term>
82 <term><replaceable class="parameter">agg_name</replaceable></term>
83 <term><replaceable class="parameter">constraint_name</replaceable></term>
84 <term><replaceable class="parameter">func_name</replaceable></term>
85 <term><replaceable class="parameter">op</replaceable></term>
86 <term><replaceable class="parameter">rule_name</replaceable></term>
87 <term><replaceable class="parameter">trigger_name</replaceable></term>
90 The name of the object to be commented. Names of tables,
91 aggregates, domains, functions, indexes, operators, operator classes,
92 sequences, types, and views may be schema-qualified.
98 <term><replaceable class="parameter">agg_type</replaceable></term>
101 The argument data type of the aggregate function, or
102 <literal>*</literal> if the function accepts any data type.
108 <term><replaceable class="parameter">large_object_oid</replaceable></term>
111 The OID of the large object.
117 <term><literal>PROCEDURAL</literal></term>
121 This is a noise word.
127 <term><replaceable>sourcetype</replaceable></term>
130 The name of the source data type of the cast.
136 <term><replaceable>targettype</replaceable></term>
139 The name of the target data type of the cast.
145 <term><replaceable class="parameter">text</replaceable></term>
148 The new comment, written as a string literal; or <literal>NULL</>
161 A comment for a database can only be created in that database,
162 and will only be visible in that database, not in other databases.
166 There is presently no security mechanism for comments: any user
167 connected to a database can see all the comments for objects in
168 that database (although only superusers can change comments for
169 objects that they don't own). Therefore, don't put
170 security-critical information in comments.
175 <title>Examples</title>
178 Attach a comment to the table <literal>mytable</literal>:
181 COMMENT ON TABLE mytable IS 'This is my table.';
187 COMMENT ON TABLE mytable IS NULL;
195 COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance';
196 COMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';
197 COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
198 COMMENT ON CONVERSION my_conv IS 'Conversion to Unicode';
199 COMMENT ON DATABASE my_database IS 'Development Database';
200 COMMENT ON DOMAIN my_domain IS 'Email Address Domain';
201 COMMENT ON FUNCTION my_function (timestamp) IS 'Returns Roman Numeral';
202 COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee ID';
203 COMMENT ON LANGUAGE plpython IS 'Python support for stored procedures';
204 COMMENT ON LARGE OBJECT 346344 IS 'Planning document';
205 COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';
206 COMMENT ON OPERATOR ^ (NONE, text) IS 'This is a prefix operator on text';
207 COMMENT ON OPERATOR CLASS int4ops USING btree IS '4 byte integer operators for btrees';
208 COMMENT ON RULE my_rule ON my_table IS 'Logs updates of employee records';
209 COMMENT ON SCHEMA my_schema IS 'Departmental data';
210 COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';
211 COMMENT ON TABLE my_schema.my_table IS 'Employee Information';
212 COMMENT ON TRIGGER my_trigger ON my_table IS 'Used for RI';
213 COMMENT ON TYPE complex IS 'Complex number data type';
214 COMMENT ON VIEW my_view IS 'View of departmental costs';
220 <title>Compatibility</title>
223 There is no <command>COMMENT</command> command in the SQL standard.
228 <!-- Keep this comment at the end of the file
233 sgml-minimize-attributes:nil
234 sgml-always-quote-attributes:t
237 sgml-parent-document:nil
238 sgml-default-dtd-file:"../reference.ced"
239 sgml-exposed-tags:nil
240 sgml-local-catalogs:"/usr/lib/sgml/catalog"
241 sgml-local-ecat-files:nil