Re: ALTER TABLE Column NOT NULL?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)atentus(dot)com>
Cc: Gregory Wood <gregw(at)com-stock(dot)com>, PostgreSQL-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: ALTER TABLE Column NOT NULL?
Date: 2002-01-25 20:37:36
Message-ID: 5216.1011991056@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alvaro Herrera <alvherre(at)atentus(dot)com> writes:
> ALTER TABLE table-name ADD CONSTRAINT constraint-name CHECK (column
> NOTNULL);

> Note that there cannot be any NULL value in the column (BTW, this is a
> good candidate for better error reporting)

regression=# create table foo (f1 text);
CREATE
regression=# insert into foo values(null);
INSERT 1999760 1
regression=# alter table foo add constraint f1_not_null check (f1 notnull);
ERROR: AlterTableAddConstraint: rejected due to CHECK constraint f1_not_null

What's wrong with that?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Boz Jennings 2002-01-25 21:06:52 Orionserver, CMP and PostgreSQL
Previous Message Alvaro Herrera 2002-01-25 20:09:18 Re: ALTER TABLE Column NOT NULL?