1COMMENT()                        SQL Commands                        COMMENT()
2
3
4

NAME

6       COMMENT - define or change the comment of an object
7
8

SYNOPSIS

10       COMMENT ON
11       {
12         TABLE object_name |
13         COLUMN table_name.column_name |
14         AGGREGATE agg_name (agg_type [, ...] ) |
15         CAST (sourcetype AS targettype) |
16         CONSTRAINT constraint_name ON table_name |
17         CONVERSION object_name |
18         DATABASE object_name |
19         DOMAIN object_name |
20         FUNCTION func_name ( [ [ argmode ] [ argname ] argtype [, ...] ] ) |
21         INDEX object_name |
22         LARGE OBJECT large_object_oid |
23         OPERATOR op (leftoperand_type, rightoperand_type) |
24         OPERATOR CLASS object_name USING index_method |
25         [ PROCEDURAL ] LANGUAGE object_name |
26         ROLE object_name |
27         RULE rule_name ON table_name |
28         SCHEMA object_name |
29         SEQUENCE object_name |
30         TABLESPACE object_name |
31         TRIGGER trigger_name ON table_name |
32         TYPE object_name |
33         VIEW object_name
34       } IS 'text'
35
36

DESCRIPTION

38       COMMENT stores a comment about a database object.
39
40       To  modify  a comment, issue a new COMMENT command for the same object.
41       Only one comment string is stored for each object.  To  remove  a  com‐
42       ment,  write  NULL in place of the text string.  Comments are automati‐
43       cally dropped when the object is dropped.
44
45       Comments can be easily retrieved with the psql commands \dd,  \d+,  and
46       \l+.   Other user interfaces to retrieve comments can be built atop the
47       same  built-in  functions  that  psql  uses,  namely   obj_description,
48       col_description, and shobj_description (see in the documentation).
49

PARAMETERS

51       object_name
52
53       table_name.column_name
54
55       agg_name
56
57       constraint_name
58
59       func_name
60
61       op
62
63       rule_name
64
65       trigger_name
66              The  name of the object to be commented. Names of tables, aggre‐
67              gates, domains, functions, indexes, operators, operator classes,
68              sequences, types, and views may be schema-qualified.
69
70       agg_type
71              An input data type on which the aggregate function operates.  To
72              reference a zero-argument aggregate function, write *  in  place
73              of the list of input data types.
74
75       sourcetype
76              The name of the source data type of the cast.
77
78       targettype
79              The name of the target data type of the cast.
80
81       argmode
82              The  mode  of  a function argument: either IN, OUT, or INOUT. If
83              omitted, the default is IN.  Note that COMMENT ON FUNCTION  does
84              not  actually pay any attention to OUT arguments, since only the
85              input arguments are needed to determine the function's identity.
86              So it is sufficient to list the IN and INOUT arguments.
87
88       argname
89              The  name of a function argument.  Note that COMMENT ON FUNCTION
90              does not actually pay any attention  to  argument  names,  since
91              only  the  argument data types are needed to determine the func‐
92              tion's identity.
93
94       argtype
95              The data type(s) of the function's arguments (optionally schema-
96              qualified), if any.
97
98       large_object_oid
99              The OID of the large object.
100
101       PROCEDURAL
102              This is a noise word.
103
104       text   The  new  comment,  written as a string literal; or NULL to drop
105              the comment.
106

NOTES

108       There is presently no security mechanism for comments:  any  user  con‐
109       nected to a database can see all the comments for objects in that data‐
110       base (although only superusers can change  comments  for  objects  that
111       they  don't  own).  For  shared  objects  such as databases, roles, and
112       tablespaces comments are stored globally and any user connected to  any
113       database  can see all the comments for shared objects. Therefore, don't
114       put security-critical information in comments.
115

EXAMPLES

117       Attach a comment to the table mytable:
118
119       COMMENT ON TABLE mytable IS 'This is my table.';
120
121       Remove it again:
122
123       COMMENT ON TABLE mytable IS NULL;
124
125
126       Some more examples:
127
128       COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance';
129       COMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';
130       COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
131       COMMENT ON CONVERSION my_conv IS 'Conversion to UTF8';
132       COMMENT ON DATABASE my_database IS 'Development Database';
133       COMMENT ON DOMAIN my_domain IS 'Email Address Domain';
134       COMMENT ON FUNCTION my_function (timestamp) IS 'Returns Roman Numeral';
135       COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee ID';
136       COMMENT ON LANGUAGE plpython IS 'Python support for stored procedures';
137       COMMENT ON LARGE OBJECT 346344 IS 'Planning document';
138       COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';
139       COMMENT ON OPERATOR - (NONE, text) IS 'This is a prefix operator on text';
140       COMMENT ON OPERATOR CLASS int4ops USING btree IS '4 byte integer operators for btrees';
141       COMMENT ON ROLE my_role IS 'Administration group for finance tables';
142       COMMENT ON RULE my_rule ON my_table IS 'Logs updates of employee records';
143       COMMENT ON SCHEMA my_schema IS 'Departmental data';
144       COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';
145       COMMENT ON TABLE my_schema.my_table IS 'Employee Information';
146       COMMENT ON TABLESPACE my_tablespace IS 'Tablespace for indexes';
147       COMMENT ON TRIGGER my_trigger ON my_table IS 'Used for RI';
148       COMMENT ON TYPE complex IS 'Complex number data type';
149       COMMENT ON VIEW my_view IS 'View of departmental costs';
150
151

COMPATIBILITY

153       There is no COMMENT command in the SQL standard.
154
155
156
157SQL - Language Statements         2008-06-08                         COMMENT()
Impressum