Re: Changing NOT NULL condition on column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bob Smith <bsmith(at)h-e(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Changing NOT NULL condition on column
Date: 2003-05-21 03:58:44
Message-ID: 4588.1053489524@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Bob Smith <bsmith(at)h-e(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message A.Bhuvaneswaran 2003-05-21 05:34:39 Logfile removal
Previous Message Bob Smith 2003-05-20 23:40:34 Changing NOT NULL condition on column