Re: Altering a table in Postgres to add a NOT NULL constraint - Mailing list pgsql-novice

From Ron Johnson
Subject Re: Altering a table in Postgres to add a NOT NULL constraint
Date
Msg-id 1022459741.10220.328.camel@rebel
Whole thread Raw
List pgsql-novice
Hi, Jason.

On Wed, 2002-05-22 at 20:54, Jason Cernansky wrote:
> The following statement should allow you to add a not null constraint to
> a table:
>
> ALTER TABLE tablename ADD CONSTRAINT notnullchk CHECK (columnname IS NOT
> NULL);

Thanks for showing me how to prevent NULLs.  Unfortunately,
that command is a column-level CHECK constraint, not a NOT
NULL constraint needed by ALTER TABLE ... PRIMARY KEY.

How do I know?  I tried it...

So, I now have to reload the table...

--
+---------------------------------------------------------+
| Ron Johnson, Jr.        Home: ron.l.johnson@cox.net     |
| Jefferson, LA  USA      http://ronandheather.dhs.org:81 |
|                                                         |
| "I have created a government of whirled peas..."        |
|   Maharishi Mahesh Yogi, 12-May-2002,                   |
!   CNN, Larry King Live                                  |
+---------------------------------------------------------+


pgsql-novice by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Copy Comand question
Next
From: "Adam Erickson"
Date:
Subject: Possible use of a subselect?