Re: Altering a table in Postgres to add a NOT NULL constraint

From: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
To: Jason Cernansky <jason(at)iradix(dot)com>
Cc: PgSQL Novice ML <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Altering a table in Postgres to add a NOT NULL constraint
Date: 2002-05-27 00:35:40
Message-ID: 1022459741.10220.328.camel@rebel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)l(dot)johnson(at)cox(dot)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 |
+---------------------------------------------------------+

Browse pgsql-novice by date

  From Date Subject
Next Message Adam Erickson 2002-05-27 04:43:50 Possible use of a subselect?
Previous Message Volker Roehl 2002-05-26 08:45:46 german decimal / locale