Re: [GENERAL] When to use COMMENT vs -- - Mailing list pgsql-general

From Merlin Moncure
Subject Re: [GENERAL] When to use COMMENT vs --
Date
Msg-id CAHyXU0yxAcJt-6KSRAf=aPALTiYvAsv-EL4LwF2eFSNr6QGJLw@mail.gmail.com
Whole thread Raw
In response to When to use COMMENT vs --  (Rich Shepard <rshepard@appl-ecosys.com>)
List pgsql-general
On Wed, Dec 7, 2016 at 9:57 AM, Rich Shepard <rshepard@appl-ecosys.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


pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: [GENERAL] Multidimentional array access
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] Multidimentional array access