Search Postgresql Archives

Re: When to use COMMENT vs --

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Rich

> -----Original Message-----
> From: pgsql-general-owner@xxxxxxxxxxxxxx [mailto:pgsql-general-owner@xxxxxxxxxxxxxx] On Behalf Of Chris Travers
> Sent: Mittwoch, 7. Dezember 2016 17:12
> To: Postgres General <pgsql-general@xxxxxxxxxxxxxx>
> Subject: Re:  When to use COMMENT vs --
> 
> On Dec 7, 2016 5:07 PM, "Karsten Hilbert" <Karsten.Hilbert@xxxxxxx <mailto:Karsten.Hilbert@xxxxxxx> > wrote:
> >
> > On Wed, Dec 07, 2016 at 07:57:54AM -0800, Rich Shepard wrote:
> >
> > >   I have used '-- ' to enter comments about tables or columns and am
> > > curious about the value of storing comments in tables using the COMMENT key word.
> > > When is the latter more appropriate than the former?
> >
> > "--" only means "comment" to SQL code (such as in scripts).
> > PostgreSQL itself simply ignores it.
> >
> > OTOH, using "comment on ... is ..." tells PostgreSQL to _store_ a
> > comment on a database object for later retrieval.
> >
> 
> This also means that tools like pg_autodoc can include it as part of the generated documentation.

All of the relevant differences have been mentioned by previous posters. IMHO the fact mentioned by Chris Travers that comments on objects included in the database can be used by tools to generate the documentation is probably the most important (besides their being persisted). As a matter of fact we have integrated this feature to extract comments to generate the DB documentation in our internal MediaWiki based wiki.

If you are interested in more details on that, including additional reasons why it is a good idea to use "comments on" instead of comments in the source code, you may have a look at this presentation:

http://www.schmiedewerkstatt.ch/documents/04-publications/integrating_postgresql_documentation_in_3rd_party_applications_handout_pdfa.pdf

Bye
Charles

> > Karsten
> > --
> > GPG key ID E4071346 @ eu.pool.sks-keyservers.net
> > <http://eu.pool.sks-keyservers.net>
> > E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
> >
> >
> > --
> > Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx
> > <mailto:pgsql-general@xxxxxxxxxxxxxx> ) To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-general
> 




-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux