Re: adding column with not null constraint - Mailing list pgsql-sql

From Johannes Lochmann
Subject Re: adding column with not null constraint
Date
Msg-id 1035127600.30905.5.camel@chello213047228041.tirol.surfer.at
Whole thread Raw
In response to adding column with not null constraint  (Vivek Khera <khera@kcilink.com>)
List pgsql-sql
On Fri, 2002-10-18 at 22:12, Vivek Khera wrote:
> ALTER TABLE msg_owner ADD COLUMN user_optional_fields VARCHAR(255);
> ALTER TABLE msg_owner ALTER user_optional_fields SET DEFAULT '';
> UPDATE msg_owner SET user_optional_fields = '';
> 
> Now my problem is I cannot find any syntax for ALTER TABLE ADD
> CONSTRAINT to put a NOT NULL constraint on a column.  Can someone help
> me here?

An additional thought to what mallah@trade-india.com said:

BEGIN;

ALTER TABLE msg_owner ADD CONSTRAINT chk_msg_owner_usr_opt_flds_null
CHECK(user_optional_fields IS NOT NULL);

COMMIT;

HTH

Johannes Lochmann



pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: indexing on char vs varchar
Next
From: Ludwig Lim
Date:
Subject: Re: Restricting a VIEW.