<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title> Practical PostgreSQL</title> <meta name="keywords" content="postgresql, support, recovery, design, software, hosting, expterise, programming, postgres, pgsql, replication, mysql, firebird, database, sql, free, open source, software" /> <meta name="description" content="Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. " /> <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" /> <link rel="stylesheet" type="text/css" href="../css/layout.css" /> <link rel="stylesheet" type="text/css" href="../css/cmd4.css" /> <script language="javascript" type="text/javascript"><!-- greymenuhomewideLit = new Image(); greymenuhomewideLit.src = "/images/greymenu_homewide_lit.gif"; greymenuaboutLit = new Image(); greymenuaboutLit.src = "/images/greymenu_about_lit.gif"; greymenuproductsLit = new Image(); greymenuproductsLit.src = "/images/greymenu_products_lit.gif"; greymenuservicesLit = new Image(); greymenuservicesLit.src = "/images/greymenu_services_lit.gif"; greymenusupportLit = new Image(); greymenusupportLit.src = "/images/greymenu_support_lit.gif"; greymenucommunityLit = new Image(); greymenucommunityLit.src = "/images/greymenu_community_lit.gif"; //--></script> </head> <body> <div align="center"> <div id="widecontainer"> <div id="widetop"> <div class="throwleft" style="width: 300px; text-align: left;"><a href="http://www.commandprompt.com/"><img src="../images/cmd4logo_wide.gif" border="0" alt="Command Prompt, Inc." /></a></div> <div class="throwright" style="width: 400px; text-align: right;"> <div id="topright"> <form action="index.html" name="cmdform" method="post"> <ul> <li><input type="text" name="search" value="" /></li> <li><input type="submit" name="action" value="Search Book" /></li> </ul> </form> </div> </div> </div> <ul id="greymenu_wide"> <li><a href="http://www.commandprompt.com/home/"><img onmouseover="this.src = greymenuhomewideLit.src;" onmouseout="this.src = '/images/greymenu_homewide.gif';" src="../images/greymenu_homewide.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/about/"><img onmouseover="this.src = greymenuaboutLit.src;" onmouseout="this.src = '/images/greymenu_about.gif';" src="../images/greymenu_about.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/products/"><img onmouseover="this.src = greymenuproductsLit.src;" onmouseout="this.src = '/images/greymenu_products.gif';" src="../images/greymenu_products.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/services/"><img onmouseover="this.src = greymenuservicesLit.src;" onmouseout="this.src = '/images/greymenu_services.gif';" src="../images/greymenu_services.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/support/"><img onmouseover="this.src = greymenusupportLit.src;" onmouseout="this.src = '/images/greymenu_support.gif';" src="../images/greymenu_support.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/community/"><img onmouseover="this.src = greymenucommunityLit.src;" onmouseout="this.src = '/images/greymenu_community.gif';" src="../images/greymenu_community.gif" border="0" height="22" title="" alt="" /></a></li> </ul> <div style="padding-left: 16px; width: 96%;"> <HTML ><HEAD ><TITLE >COMMENT</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.72 "><LINK REL="HOME" TITLE="Practical PostgreSQL" href="book1"><LINK REL="UP" TITLE="PostgreSQL Command Reference" href="c22759"><LINK REL="PREVIOUS" TITLE="CLUSTER" href="r23217"><LINK REL="NEXT" TITLE="COMMIT" href="r23479"></HEAD ><BODY CLASS="REFENTRY" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Practical PostgreSQL</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A href="r23217" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A href="r23479" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="SQL-COMMENT" >COMMENT</A ></H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN23309" ></A ><H2 >Name</H2 >COMMENT -- Adds a comment to an object within the database.</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN23312" ></A ><H2 >Synopsis</H2 ><PRE CLASS="SYNOPSIS" >COMMENT ON [ [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ] <TT CLASS="REPLACEABLE" ><I >object_name</I ></TT > | COLUMN <TT CLASS="REPLACEABLE" ><I >table_name</I ></TT >.<TT CLASS="REPLACEABLE" ><I >column_name</I ></TT > | FUNCTION <TT CLASS="REPLACEABLE" ><I >func_name</I ></TT > ( <TT CLASS="REPLACEABLE" ><I >argument</I ></TT > [, ...] ) | AGGREGATE <TT CLASS="REPLACEABLE" ><I >aggr_func</I ></TT > <TT CLASS="REPLACEABLE" ><I >aggr_type</I ></TT > | OPERATOR <TT CLASS="REPLACEABLE" ><I >operator</I ></TT > ( <TT CLASS="REPLACEABLE" ><I >left_type</I ></TT > , <TT CLASS="REPLACEABLE" ><I >right_type</I ></TT > ) | TRIGGER <TT CLASS="REPLACEABLE" ><I >trigger_name</I ></TT > ON <TT CLASS="REPLACEABLE" ><I >table_name</I ></TT > ] IS <TT CLASS="REPLACEABLE" ><I >'text'</I ></TT ></PRE ><DIV CLASS="REFSECT2" ><A NAME="R2-SQL-COMMENT-1" ></A ><H3 >Parameters</H3 ><P > <P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="LITERAL" >DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW</TT ></DT ><DD ><P >The type of database object that you are adding a comment to.</P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >object_name</I ></TT ></DT ><DD ><P >The name of the object (<TT CLASS="LITERAL" >database</TT >, <TT CLASS="LITERAL" >index</TT >, <TT CLASS="LITERAL" >rule</TT >, <TT CLASS="LITERAL" >sequence</TT >, <TT CLASS="LITERAL" >table</TT >, <TT CLASS="LITERAL" >type</TT >, or <TT CLASS="LITERAL" >view</TT >) to which you are adding a comment.</P ></DD ><DT ><TT CLASS="LITERAL" >COLUMN</TT > <TT CLASS="REPLACEABLE" ><I >table_name.column_name</I ></TT ></DT ><DD ><P >The column name within <TT CLASS="REPLACEABLE" ><I >table_name</I ></TT > you are adding a comment to. </P ></DD ><DT ><TT CLASS="LITERAL" >FUNCTION</TT > <TT CLASS="REPLACEABLE" ><I >func_name</I ></TT > <TT CLASS="LITERAL" >(</TT > <TT CLASS="REPLACEABLE" ><I >argument</I ></TT > <TT CLASS="LITERAL" >[, ...] )</TT ></DT ><DD ><P >The name of the function on which you are commenting, specified also by the argument data types that it accepts.</P ></DD ><DT ><TT CLASS="LITERAL" >AGGREGATE</TT > <TT CLASS="REPLACEABLE" ><I >aggr_func aggr_type</I ></TT ></DT ><DD ><P >The aggregate function name (and associated data type <TT CLASS="REPLACEABLE" ><I >aggr_type</I ></TT >, which it accepts) to which you are adding a comment.</P ></DD ><DT ><TT CLASS="LITERAL" >OPERATOR</TT > <TT CLASS="REPLACEABLE" ><I >operator</I ></TT > ( <TT CLASS="REPLACEABLE" ><I >left_type</I ></TT >, <TT CLASS="REPLACEABLE" ><I >right_type</I ></TT > )</DT ><DD ><P >The name of the operator on which you are commenting (<TT CLASS="REPLACEABLE" ><I >operator</I ></TT >), further described by the data type it operates on to the left, and the data type it operates on to the right, separated by a comma, enclosed within parentheses. If either side is inapplicable, the <TT CLASS="LITERAL" >NONE</TT > keyword may be used.</P ></DD ><DT ><TT CLASS="LITERAL" >TRIGGER</TT > <TT CLASS="REPLACEABLE" ><I >trigger_name ON table_name</I ></TT ></DT ><DD ><P >The name of the trigger on which you are placing a comment, and the name of the table upon which the trigger is placed.</P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >text</I ></TT ></DT ><DD ><P >The actual text of the comment to add.</P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="REFSECT2" ><A NAME="R2-SQL-COMMENT-2" ></A ><H3 >Results</H3 ><P > <P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="LITERAL" >COMMENT</TT ></DT ><DD ><P >The message returned when an object is successfully commented.</P ></DD ></DL ></DIV > </P ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="R1-SQL-COMMENT-1" ></A ><H2 >Description</H2 ><P ><TT CLASS="LITERAL" >COMMENT</TT > is a PostgreSQL-specific command that allows you to add comments to most objects within a database, including a database itself. Comments can be retrieved by using the following commands from within the <SPAN ><I CLASS="EMPHASIS" >psql</I ></SPAN > client: </P ><P > <P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="LITERAL" >\l+</TT ></DT ><DD ><P > Displays all databases available, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\dd</TT ></DT ><DD ><P > Displays <SPAN ><I CLASS="EMPHASIS" >all</I ></SPAN > database objects, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\d+</TT ></DT ><DD ><P > Displays all database objects in the connected database, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\dt+</TT ></DT ><DD ><P > Displays all tables in the connected database, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\di+</TT ></DT ><DD ><P > Displays all indices in the connected database, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\ds+</TT ></DT ><DD ><P > Displays all sequences in the connected database, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\dv+</TT ></DT ><DD ><P > Displays all views in the connected database, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\df+</TT ></DT ><DD ><P > Displays all functions in the connected database, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\da+</TT ></DT ><DD ><P > Displays all aggregate functions in the connected database, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\do+</TT ></DT ><DD ><P > Displays all operators in the connected database, with comments. </P ></DD ><DT ><TT CLASS="LITERAL" >\dT+</TT ></DT ><DD ><P > Displays all data types in the connected database, with comments. </P ></DD ></DL ></DIV > </P ><P >You can remove a comment by setting its <TT CLASS="REPLACEABLE" ><I >text</I ></TT > to <TT CLASS="LITERAL" >NULL</TT >.</P ><DIV CLASS="NOTE" ><BLOCKQUOTE CLASS="NOTE" ><P ><B >Note: </B >A comment that has been made on an object will be removed when that object is removed from the system.</P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="R1-SQL-COMMENT-2" ></A ><H2 >Examples</H2 ><P >The following example adds a comment to the <TT CLASS="LITERAL" >customers</TT > table:</P ><PRE CLASS="SCREEN" >booktown=# <TT CLASS="USERINPUT" ><B >COMMENT ON TABLE customers IS 'For customer names.';</B ></TT > COMMENT</PRE ><P >The next example deletes the previously added comment from the <TT CLASS="LITERAL" >customer</TT > table:</P ><PRE CLASS="SCREEN" >booktown=# <TT CLASS="USERINPUT" ><B >COMMENT ON TABLE customers IS NULL</B ></TT >;</PRE ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A href="r23217" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A href="book1" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A href="r23479" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >CLUSTER</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A href="c22759" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >COMMIT</TD ></TR ></TABLE ></DIV ></BODY ></HTML > </div> <br /> <div id="thefineprint"> <a href="http://www.commandprompt.com/products/mammothpostgresql/"><img src="../images/powered_by_mammoth.gif" alt="Powered by Mammoth PostgreSQL" title="Powered by Mammoth PostgreSQL" border="0" /></a> <br /> Copyright © 2000-2007 Command Prompt, Inc. All Rights Reserved. All trademarks property of their respective owners. </div> </div> </div> </body> </html>