Re: Modifying NOT NULL Constraint - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Modifying NOT NULL Constraint
Date
Msg-id 13599.960964267@sss.pgh.pa.us
Whole thread Raw
In response to Modifying NOT NULL Constraint  ("Dan Wilson" <phpPgAdmin@acucore.com>)
List pgsql-hackers
"Dan Wilson" <dan_wilson@geocities.com> writes:
> So if I'm understanding this correctly, this would be able to remove the NOT
> NULL constraint, but would not be able to set the NOT NULL constraint.  Is
> that correct?

Oh, you can set attnotnull if you feel like it.  My point is just that
nothing much will happen to any existing null values in the column.
It's up to you to check for them first, if you care.

> If that is correct, are their plans to implement a post-create setting of
> the NOT NULL constraint?

What do you think should happen if there are null values?  Refuse the
command?  Delete the non-compliant rows?  Allow the rows to remain
even though the column is now nominally NOT NULL?

You can implement any of these behaviors for yourself with a couple of
SQL commands inside a transaction, so I'm not sure that I see the need
to have a neatly-wrapped-up ALTER TABLE command that will only do one
of the things you might want it to do.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Adding time to DATE type
Next
From: "Dan Wilson"
Date:
Subject: Re: Modifying NOT NULL Constraint