Skip site navigation (1) Skip section navigation (2)

Re: Message about not null in ALTER TABLE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)atentus(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Message about not null in ALTER TABLE
Date: 2002-01-22 20:55:45
Message-ID: 28347.1011732945@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Alvaro Herrera <alvherre(at)atentus(dot)com> writes:
> However, there is no way to add a NOT NULL constraint to an existing
> column in a table, so the error message is misleading.

Sure there is:

regression=# create table test (a int);
CREATE
regression=#  alter table test add column b int not null;
ERROR:  Adding NOT NULL columns is not implemented.
        Add the column, then use ALTER TABLE ADD CONSTRAINT.
regression=#  alter table test add column b int;
ALTER
regression=# alter table test add constraint bnotnull check (b notnull);
ALTER
regression=#

It'd be nice to have more ALTER TABLE variants implemented, but it's
not true that you can't get the functionality nohow...

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2002-01-22 21:08:06
Subject: Re: A Chinese handling bug
Previous:From: Bruce MomjianDate: 2002-01-22 20:28:55
Subject: Re: A Chinese handling bug

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group