Re: When to use COMMENT vs --

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: When to use COMMENT vs --
Date: 2016-12-09 15:23:19
Message-ID: CAHyXU0yxAcJt-6KSRAf=aPALTiYvAsv-EL4LwF2eFSNr6QGJLw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Dec 7, 2016 at 9:57 AM, Rich Shepard <rshepard(at)appl-ecosys(dot)com> 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?

Main advantage of COMMENT is that the comments are transferred to the
database such that the comments will be made available to client tools
(like psql) and external programs. For example, if you are generating
database diagrams out of the database automatically (which is a good
idea) with a good tool (I recommend SchemaSpy) the comments will
become visible.

Code style comments OTOH will decorate the file. This is good if you
maintain your code as proper code, checking it into git and such,
which is also a very good idea.

Personally I tend to avoid COMMENT on aesthetics; I just dislike the
COMMENT section to *after* the object being created in code. If I had
a hypothetical "COMMENT ON NEXT OBJECT 'This is ...';" I would
probably use COMMENT a lot more :-).

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-12-09 15:30:39 Re: Multidimentional array access
Previous Message Pavel Stehule 2016-12-09 15:17:42 Re: Multidimentional array access