Re: How to drop a NOT NULL column constraint?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ed Loehr <eloehr(at)austin(dot)rr(dot)com>
Cc: pggeneral <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to drop a NOT NULL column constraint?
Date: 2001-01-02 18:04:23
Message-ID: 12983.978458663@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ed Loehr <eloehr(at)austin(dot)rr(dot)com> writes:
> I need to alter the table to get rid of the "NOT NULL" constraint on the
> 'id' column. Can I do this using ALTER TABLE?

There isn't an ALTER TABLE variant for this at the moment, but you can
do it the hard way: reach in and change the attnotnull boolean in the
column's pg_attribute row. The actual update would only require

UPDATE pg_attribute SET attnotnull = 'f' WHERE
attname = 'id' AND attrelid = whatever...

but I don't believe this will be noticed automatically by running
backends. I think a VACUUM on your table afterwards would be sufficient
to force the backends to notice the change.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ed Loehr 2001-01-02 18:45:48 Re: How to drop a NOT NULL column constraint?
Previous Message Brett W. McCoy 2001-01-02 18:03:42 Re: How to drop a NOT NULL column constraint?