2 $PostgreSQL: pgsql/doc/src/sgml/ref/comment.sgml,v 1.25 2003/11/29 19:51:38 pgsql 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.
55 easily retrieved with the <application>psql</application> commands
56 <command>\dd</command>, <command>\d+</command>, and <command>\l+</command>.
57 Other user interfaces to retrieve comments can be built atop
58 the same built-in functions that <application>psql</application> uses, namely
59 <function>obj_description</> and <function>col_description</>.
63 To modify a comment, issue a new <command>COMMENT</> command for the
64 same object. Only one comment string is stored for each object.
65 To remove a comment, write <literal>NULL</literal> in place of the text
67 Comments are automatically dropped when the object is dropped.
72 <title>Parameters</title>
76 <term><replaceable class="parameter">object_name</replaceable></term>
77 <term><replaceable class="parameter">table_name.column_name</replaceable></term>
78 <term><replaceable class="parameter">agg_name</replaceable></term>
79 <term><replaceable class="parameter">constraint_name</replaceable></term>
80 <term><replaceable class="parameter">func_name</replaceable></term>
81 <term><replaceable class="parameter">op</replaceable></term>
82 <term><replaceable class="parameter">rule_name</replaceable></term>
83 <term><replaceable class="parameter">trigger_name</replaceable></term>
86 The name of the object to be commented. Names of tables,
87 aggregates, domains, functions, indexes, operators, operator classes,
88 sequences, types, and views may be schema-qualified.
94 <term><replaceable class="parameter">agg_type</replaceable></term>
97 The argument data type of the aggregate function, or
98 <literal>*</literal> if the function accepts any data type.
104 <term><replaceable class="parameter">large_object_oid</replaceable></term>
107 The OID of the large object.
113 <term><literal>PROCEDURAL</literal></term>
117 This is a noise word.
123 <term><replaceable>sourcetype</replaceable></term>
126 The name of the source data type of the cast.
132 <term><replaceable>targettype</replaceable></term>
135 The name of the target data type of the cast.
141 <term><replaceable class="parameter">text</replaceable></term>
156 A comment for a database can only be created in that database,
157 and will only be visible in that database, not in other databases.
161 There is presently no security mechanism for comments: any user
162 connected to a database can see all the comments for objects in
163 that database (although only superusers can change comments for
164 objects that they don't own). Therefore, don't put
165 security-critical information in comments.
170 <title>Examples</title>
173 Attach a comment to the table <literal>mytable</literal>:
176 COMMENT ON TABLE mytable IS 'This is my table.';
182 COMMENT ON TABLE mytable IS NULL;
190 COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance';
191 COMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';
192 COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
193 COMMENT ON CONVERSION my_conv IS 'Conversion to Unicode';
194 COMMENT ON DATABASE my_database IS 'Development Database';
195 COMMENT ON DOMAIN my_domain IS 'Email Address Domain';
196 COMMENT ON FUNCTION my_function (timestamp) IS 'Returns Roman Numeral';
197 COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee ID';
198 COMMENT ON LANGUAGE plpython IS 'Python support for stored procedures';
199 COMMENT ON LARGE OBJECT 346344 IS 'Planning document';
200 COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';
201 COMMENT ON OPERATOR ^ (NONE, text) IS 'This is a prefix operator on text';
202 COMMENT ON OPERATOR CLASS int4ops USING btree IS '4 byte integer operators for btrees';
203 COMMENT ON RULE my_rule ON my_table IS 'Logs updates of employee records';
204 COMMENT ON SCHEMA my_schema IS 'Departmental data';
205 COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';
206 COMMENT ON TABLE my_schema.my_table IS 'Employee Information';
207 COMMENT ON TRIGGER my_trigger ON my_table IS 'Used for RI';
208 COMMENT ON TYPE complex IS 'Complex number data type';
209 COMMENT ON VIEW my_view IS 'View of departmental costs';
215 <title>Compatibility</title>
218 There is no <command>COMMENT</command> command in the SQL standard.
223 <!-- Keep this comment at the end of the file
228 sgml-minimize-attributes:nil
229 sgml-always-quote-attributes:t
232 sgml-parent-document:nil
233 sgml-default-dtd-file:"../reference.ced"
234 sgml-exposed-tags:nil
235 sgml-local-catalogs:"/usr/lib/sgml/catalog"
236 sgml-local-ecat-files:nil