Re: SET NULL / SET NOT NULL

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>, "Zeugswetter Andreas SB SD" <ZeugswetterA(at)spardat(dot)at>, "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SET NULL / SET NOT NULL
Date: 2002-03-25 03:24:35
Message-ID: GNELIHDDFBOCMGBFGEFOGENJCBAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> OK, how about:
>
> SET CONSTRAINT NOT NULL
>
> or
>
> DROP CONSTRAINT NOT NULL
>
> or simply:
>
> SET/DROP NOT NULL
>
> I think the problem with trying to get it look like CREATE TABLE is that
> the plain NULL parameter to CREATE TABLE is meaningless and probably
> should never be used. I remember at one point pg_dump output NULL in
> the schema output and it confused many people. NOT NULL is the
> constraint, and I think any solution to remove NOT NULL has to include
> the NOT NULL keyword. I think this is also why SET NULL looks so bad.
> "CREATE TABLE test (x int NULL)" doesn't look great either. :-) What
> is that NULL doing there?

OK, I've decided to go with:

ALTER TABLE blah ALTER [COLUMN] col SET NOT NULL;

and

ALTER TABLE blah ALTER [COLUMN] col DROP NOT NULL;

This is synchronous with the SET/DROP default stuff and is extensible in the
future to fit in with column type changing.

Of course, it can always be changed in the parser without affecting my code.

Chris

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ulrich Neumann 2002-03-25 04:27:00 Antw: Re: patch for include/utils/datetime.h to target NetWare
Previous Message Thomas Lockhart 2002-03-25 03:07:23 Re: Configuring for 64-bit integer date/time storage?