Re: SET NULL / SET NOT NULL

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: Thomas Lockhart <lockhart(at)fourpalms(dot)org>, Doug McNaught <doug(at)wireboard(dot)com>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SET NULL / SET NOT NULL
Date: 2002-02-21 03:18:19
Message-ID: 3.0.5.32.20020221141819.0361a5b0@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 18:34 20/02/02 -0800, Thomas Lockhart wrote:
>> > ALTER TABLE blah ALTER COLUMN col [ALLOW NULL | NOT NULL]
>> FWIW, I like this syntax too.
>
>What would be the drawbacks to having all portions after "col" in the
>example above be *exactly* the same as the clauses allowed in CREATE
>TABLE? So, this would be
>
> ALTER TABLE tab ALTER COLUMN col [ NULL | NOT NULL ]

This looks fine to me. The spec only talks about CHECK constraints in ALTER
TABLE, but if I had to guess the most spec-like syntax, it would be:

ALTER TABLE tab ALTER COLUMN col DROP NOT NULL

which does not seem particularly good; preserving the syntax from table
creation has to be TWTG. Do we really allow:

CREATE TABLE FOO(BAR INT NULL)

?

>In that same line of thought, how about making it more closely mimic the
>original CREATE TABLE syntax? Something like

Because the SQL spec does have ALTER TABLE...ALTER COLUMN; so we should
stick with the same syntax.

>Hmm. Or if we are going to eventually allow altering column types then
>one could include the type also.

Definitely; Chris' suggestion seems pretty good to me.

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Warner 2002-02-21 03:21:18 Re: SET NULL / SET NOT NULL
Previous Message Bruce Momjian 2002-02-21 03:12:44 test message