'\" t .\" Title: COMMENT .\" Author: The PostgreSQL Global Development Group .\" Generator: DocBook XSL Stylesheets v1.75.2 .\" Date: 2016 .\" Manual: PostgreSQL 9.5.2 Documentation .\" Source: PostgreSQL 9.5.2 .\" Language: English .\" .TH "COMMENT" "5sql" "2016" "PostgreSQL 9.5.2" "PostgreSQL 9.5.2 Documentation" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" COMMENT \- define or change the comment of an object .SH "SYNOPSIS" .sp .nf COMMENT ON { AGGREGATE \fIaggregate_name\fR ( \fIaggregate_signature\fR ) | CAST (\fIsource_type\fR AS \fItarget_type\fR) | COLLATION \fIobject_name\fR | COLUMN \fIrelation_name\fR\&.\fIcolumn_name\fR | CONSTRAINT \fIconstraint_name\fR ON \fItable_name\fR | CONSTRAINT \fIconstraint_name\fR ON DOMAIN \fIdomain_name\fR | CONVERSION \fIobject_name\fR | DATABASE \fIobject_name\fR | DOMAIN \fIobject_name\fR | EXTENSION \fIobject_name\fR | EVENT TRIGGER \fIobject_name\fR | FOREIGN DATA WRAPPER \fIobject_name\fR | FOREIGN TABLE \fIobject_name\fR | FUNCTION \fIfunction_name\fR ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) | INDEX \fIobject_name\fR | LARGE OBJECT \fIlarge_object_oid\fR | MATERIALIZED VIEW \fIobject_name\fR | OPERATOR \fIoperator_name\fR (\fIleft_type\fR, \fIright_type\fR) | OPERATOR CLASS \fIobject_name\fR USING \fIindex_method\fR | OPERATOR FAMILY \fIobject_name\fR USING \fIindex_method\fR | POLICY \fIpolicy_name\fR ON \fItable_name\fR | [ PROCEDURAL ] LANGUAGE \fIobject_name\fR | ROLE \fIobject_name\fR | RULE \fIrule_name\fR ON \fItable_name\fR | SCHEMA \fIobject_name\fR | SEQUENCE \fIobject_name\fR | SERVER \fIobject_name\fR | TABLE \fIobject_name\fR | TABLESPACE \fIobject_name\fR | TEXT SEARCH CONFIGURATION \fIobject_name\fR | TEXT SEARCH DICTIONARY \fIobject_name\fR | TEXT SEARCH PARSER \fIobject_name\fR | TEXT SEARCH TEMPLATE \fIobject_name\fR | TRANSFORM FOR \fItype_name\fR LANGUAGE \fIlang_name\fR | TRIGGER \fItrigger_name\fR ON \fItable_name\fR | TYPE \fIobject_name\fR | VIEW \fIobject_name\fR } IS \(aq\fItext\fR\(aq where \fIaggregate_signature\fR is: * | [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] | [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] ] ORDER BY [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] .fi .SH "DESCRIPTION" .PP \fBCOMMENT\fR stores a comment about a database object\&. .PP Only one comment string is stored for each object, so to modify a comment, issue a new \fBCOMMENT\fR command for the same object\&. To remove a comment, write NULL in place of the text string\&. Comments are automatically dropped when their object is dropped\&. .PP For most kinds of object, only the object\(aqs owner can set the comment\&. Roles don\(aqt have owners, so the rule for COMMENT ON ROLE is that you must be superuser to comment on a superuser role, or have the CREATEROLE privilege to comment on non\-superuser roles\&. Of course, a superuser can comment on anything\&. .PP Comments can be viewed using psql\(aqs \fB\ed\fR family of commands\&. Other user interfaces to retrieve comments can be built atop the same built\-in functions that psql uses, namely \fBobj_description\fR, \fBcol_description\fR, and \fBshobj_description\fR (see Table\ \&9.62, \(lqComment Information Functions\(rq)\&. .SH "PARAMETERS" .PP \fIobject_name\fR .br \fIrelation_name\fR\&.\fIcolumn_name\fR .br \fIaggregate_name\fR .br \fIconstraint_name\fR .br \fIfunction_name\fR .br \fIoperator_name\fR .br \fIpolicy_name\fR .br \fIrule_name\fR .br \fItrigger_name\fR .RS 4 The name of the object to be commented\&. Names of tables, aggregates, collations, conversions, domains, foreign tables, functions, indexes, operators, operator classes, operator families, sequences, text search objects, types, and views can be schema\-qualified\&. When commenting on a column, \fIrelation_name\fR must refer to a table, view, composite type, or foreign table\&. .RE .PP \fItable_name\fR .br \fIdomain_name\fR .RS 4 When creating a comment on a constraint, a table, a domain or a policy these parameters specify the name of the table or domain on which the constraint is defined\&. .RE .PP \fIsource_type\fR .RS 4 The name of the source data type of the cast\&. .RE .PP \fItarget_type\fR .RS 4 The name of the target data type of the cast\&. .RE .PP \fIargmode\fR .RS 4 The mode of a function or aggregate argument: IN, OUT, INOUT, or VARIADIC\&. If omitted, the default is IN\&. Note that \fBCOMMENT\fR does not actually pay any attention to OUT arguments, since only the input arguments are needed to determine the function\(aqs identity\&. So it is sufficient to list the IN, INOUT, and VARIADIC arguments\&. .RE .PP \fIargname\fR .RS 4 The name of a function or aggregate argument\&. Note that \fBCOMMENT\fR does not actually pay any attention to argument names, since only the argument data types are needed to determine the function\(aqs identity\&. .RE .PP \fIargtype\fR .RS 4 The data type of a function or aggregate argument\&. .RE .PP \fIlarge_object_oid\fR .RS 4 The OID of the large object\&. .RE .PP \fIleft_type\fR .br \fIright_type\fR .RS 4 The data type(s) of the operator\(aqs arguments (optionally schema\-qualified)\&. Write NONE for the missing argument of a prefix or postfix operator\&. .RE .PP PROCEDURAL .RS 4 This is a noise word\&. .RE .PP \fItype_name\fR .RS 4 The name of the data type of the transform\&. .RE .PP \fIlang_name\fR .RS 4 The name of the language of the transform\&. .RE .PP \fItext\fR .RS 4 The new comment, written as a string literal; or NULL to drop the comment\&. .RE .SH "NOTES" .PP 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\&. .SH "EXAMPLES" .PP Attach a comment to the table mytable: .sp .if n \{\ .RS 4 .\} .nf COMMENT ON TABLE mytable IS \(aqThis is my table\&.\(aq; .fi .if n \{\ .RE .\} .sp Remove it again: .sp .if n \{\ .RS 4 .\} .nf COMMENT ON TABLE mytable IS NULL; .fi .if n \{\ .RE .\} .PP Some more examples: .sp .if n \{\ .RS 4 .\} .nf COMMENT ON AGGREGATE my_aggregate (double precision) IS \(aqComputes sample variance\(aq; COMMENT ON CAST (text AS int4) IS \(aqAllow casts from text to int4\(aq; COMMENT ON COLLATION "fr_CA" IS \(aqCanadian French\(aq; COMMENT ON COLUMN my_table\&.my_column IS \(aqEmployee ID number\(aq; COMMENT ON CONVERSION my_conv IS \(aqConversion to UTF8\(aq; COMMENT ON CONSTRAINT bar_col_cons ON bar IS \(aqConstrains column col\(aq; COMMENT ON CONSTRAINT dom_col_constr ON DOMAIN dom IS \(aqConstrains col of domain\(aq; COMMENT ON DATABASE my_database IS \(aqDevelopment Database\(aq; COMMENT ON DOMAIN my_domain IS \(aqEmail Address Domain\(aq; COMMENT ON EXTENSION hstore IS \(aqimplements the hstore data type\(aq; COMMENT ON FOREIGN DATA WRAPPER mywrapper IS \(aqmy foreign data wrapper\(aq; COMMENT ON FOREIGN TABLE my_foreign_table IS \(aqEmployee Information in other database\(aq; COMMENT ON FUNCTION my_function (timestamp) IS \(aqReturns Roman Numeral\(aq; COMMENT ON INDEX my_index IS \(aqEnforces uniqueness on employee ID\(aq; COMMENT ON LANGUAGE plpython IS \(aqPython support for stored procedures\(aq; COMMENT ON LARGE OBJECT 346344 IS \(aqPlanning document\(aq; COMMENT ON MATERIALIZED VIEW my_matview IS \(aqSummary of order history\(aq; COMMENT ON OPERATOR ^ (text, text) IS \(aqPerforms intersection of two texts\(aq; COMMENT ON OPERATOR \- (NONE, integer) IS \(aqUnary minus\(aq; COMMENT ON OPERATOR CLASS int4ops USING btree IS \(aq4 byte integer operators for btrees\(aq; COMMENT ON OPERATOR FAMILY integer_ops USING btree IS \(aqall integer operators for btrees\(aq; COMMENT ON POLICY my_policy ON mytable IS \(aqFilter rows by users\(aq; COMMENT ON ROLE my_role IS \(aqAdministration group for finance tables\(aq; COMMENT ON RULE my_rule ON my_table IS \(aqLogs updates of employee records\(aq; COMMENT ON SCHEMA my_schema IS \(aqDepartmental data\(aq; COMMENT ON SEQUENCE my_sequence IS \(aqUsed to generate primary keys\(aq; COMMENT ON SERVER myserver IS \(aqmy foreign server\(aq; COMMENT ON TABLE my_schema\&.my_table IS \(aqEmployee Information\(aq; COMMENT ON TABLESPACE my_tablespace IS \(aqTablespace for indexes\(aq; COMMENT ON TEXT SEARCH CONFIGURATION my_config IS \(aqSpecial word filtering\(aq; COMMENT ON TEXT SEARCH DICTIONARY swedish IS \(aqSnowball stemmer for Swedish language\(aq; COMMENT ON TEXT SEARCH PARSER my_parser IS \(aqSplits text into words\(aq; COMMENT ON TEXT SEARCH TEMPLATE snowball IS \(aqSnowball stemmer\(aq; COMMENT ON TRANSFORM FOR hstore LANGUAGE plpythonu IS \(aqTransform between hstore and Python dict\(aq; COMMENT ON TRIGGER my_trigger ON my_table IS \(aqUsed for RI\(aq; COMMENT ON TYPE complex IS \(aqComplex number data type\(aq; COMMENT ON VIEW my_view IS \(aqView of departmental costs\(aq; .fi .if n \{\ .RE .\} .SH "COMPATIBILITY" .PP There is no \fBCOMMENT\fR command in the SQL standard\&.