Re: Column COMMENTs in CREATE TABLE?

From: David Fetter <david(at)fetter(dot)org>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Marko Tiikkaja <marko(at)joh(dot)to>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column COMMENTs in CREATE TABLE?
Date: 2016-07-03 02:12:21
Message-ID: 20160703021221.GA4204@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jul 02, 2016 at 01:06:49PM -0400, David G. Johnston wrote:
> On Sat, Jul 2, 2016 at 12:55 PM, Marko Tiikkaja <marko(at)joh(dot)to> wrote:
>
> >
> > What I would prefer is something like this:
> >
> > CREATE TABLE foo(
> > f1 int NOT NULL COMMENT
> > 'the first field',
> > f2 int NOT NULL COMMENT
> > 'the second field',
> > ...
> > );
> >
> > which would ensure the comments are both next to the field definition
> > they're documenting and that they make it all the way to the database. I
> > looked into the biggest products, and MySQL supports this syntax. I
> > couldn't find any similar syntax in any other product.
> >
> >
> ​+1 for the idea - though restricting it to columns would not be ideal.

+1 for adding it to all the CREATEs whose objects support COMMENT.

Might something like

CREATE ... [WITH (COMMENT $$Big honking comment here$$)]

for the explicit CREATE cases and something like

CREATE TABLE foo(
id SERIAL PRIMARY KEY WITH (COMMENT 'Generated primary key, best find a natural one, too'),
t TEXT NOT NULL WITH (COMMENT 'Really? A single-letter name?!?'),
...
)

for cases where the CREATE isn't part of the syntax help alleviate the
keyword issue?

I suggested doing it this way because where there's one thing, in this
case a COMMENT, it's reasonable to expect that there will be others
and make that simpler to do.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Steele 2016-07-03 03:06:42 Re: Password identifiers, protocol aging and SCRAM protocol
Previous Message Euler Taveira 2016-07-03 01:32:36 Re: to_date_valid()