How to ALTER COLUMN to set a constraint of not null?

From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: How to ALTER COLUMN to set a constraint of not null?
Date: 2003-01-14 09:32:27
Message-ID: 3E23D92B.4020703@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The iDocs state that:

"In the current implementation of ADD COLUMN, default and NOT NULL
clauses for the new column are not supported. You can use the SET
DEFAULT form of ALTER TABLE to set the default later."

How does one add a "NOT NULL" constraint to a new column? I've tried
this but with no success:

JC=# alter table credit_card_names add column number_length int2;
ALTER TABLE
JC=# alter table credit_card_names alter column number_length set
default not null;
ERROR: Column "number_length" is of type smallint but default
expression is of type boolean
You will need to rewrite or cast the expression

Jc

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Aurangzeb M. Agha 2003-01-14 09:35:44 Re: PostgreSQL on Windows
Previous Message Çağıl Şeker 2003-01-14 08:24:21 DATESTYLE