1COMMENT(7)                       SQL Commands                       COMMENT(7)
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         OPERATOR FAMILY object_name USING index_method |
26         [ PROCEDURAL ] LANGUAGE object_name |
27         ROLE object_name |
28         RULE rule_name ON table_name |
29         SCHEMA object_name |
30         SEQUENCE object_name |
31         TABLESPACE object_name |
32         TEXT SEARCH CONFIGURATION object_name |
33         TEXT SEARCH DICTIONARY object_name |
34         TEXT SEARCH PARSER object_name |
35         TEXT SEARCH TEMPLATE object_name |
36         TRIGGER trigger_name ON table_name |
37         TYPE object_name |
38         VIEW object_name
39       } IS 'text'
40
41

DESCRIPTION

43       COMMENT stores a comment about a database object.
44
45       To  modify  a comment, issue a new COMMENT command for the same object.
46       Only one comment string is stored for each object.  To  remove  a  com‐
47       ment,  write  NULL in place of the text string.  Comments are automati‐
48       cally dropped when the object is dropped.
49
50       Comments can be viewed using psql's \d family of commands.  Other  user
51       interfaces  to  retrieve  comments  can be built atop the same built-in
52       functions that psql uses, namely obj_description, col_description,  and
53       shobj_description (see in the documentation).
54

PARAMETERS

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

NOTES

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

EXAMPLES

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

COMPATIBILITY

165       There is no COMMENT command in the SQL standard.
166
167
168
169SQL - Language Statements         2011-09-22                        COMMENT(7)
Impressum