Re: Changing NOT NULL condition on column - Mailing list pgsql-admin

From Tom Lane
Subject Re: Changing NOT NULL condition on column
Date
Msg-id 4588.1053489524@sss.pgh.pa.us
Whole thread Raw
In response to Changing NOT NULL condition on column  (Bob Smith <bsmith@h-e.com>)
List pgsql-admin
Bob Smith <bsmith@h-e.com> writes:
> I need to change the not-null restriction on some columns in a table,
> and this doesn't seem to be possible with ALTER TABLE.  Is it safe to
> connect as superuser and update pg_attribute.attnotnull directly?

Yeah.  I am not certain offhand that currently-running backends would
notice such a change, but at worst starting new sessions would cause
them to honor it.

> I'm currently running 7.2.3, but will be upgrading soon so I'd like to
> know if this would work with 7.3 as well.

In 7.3 there are ALTER TABLE variants to handle this more cleanly.

            regards, tom lane

pgsql-admin by date:

Previous
From: Bob Smith
Date:
Subject: Changing NOT NULL condition on column
Next
From: "A.Bhuvaneswaran"
Date:
Subject: Logfile removal