ADD CONSTRAINT NOT NULL, how?

From: Lutz Horn <lutz(at)lutz-horn(dot)de>
To: Pgsql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: ADD CONSTRAINT NOT NULL, how?
Date: 2002-05-18 10:20:11
Message-ID: 20020518102011.GA1420@lutz-horn.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi all,

I'm trying to add a column with "NOT NULL" to an existing table using
the ALTER TABLE command.

db=> ALTER TABLE t1 ADD COLUMN f2 integer NOT NULL;
ERROR: Adding NOT NULL columns is not implemented.
Add the column, then use ALTER TABLE ADD CONSTRAINT.

OK, this is not the way to do it. The solution seems to be to first add
the column without "NOT NULL" and use "ADD CONSTRAINT" later. My problem
ist: what ist the syntax for adding this constraint?

BTW, im running "PostgreSQL 7.2.1 on i686-pc-linux-gnu".

Regards
Lutz

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message bob parker 2002-05-18 11:13:40 Re upgrading 7.1 to 7.2
Previous Message gerry.smit 2002-05-17 16:15:25 Re: Answering my own question