Re: adding column with not null constraint

From: Johannes Lochmann <johannes(dot)lochmann(at)chello(dot)at>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: adding column with not null constraint
Date: 2002-10-20 15:26:39
Message-ID: 1035127600.30905.5.camel@chello213047228041.tirol.surfer.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)trade-india(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ludwig Lim 2002-10-21 02:51:07 Re: Restricting a VIEW.
Previous Message Bruce Momjian 2002-10-20 02:59:53 Re: indexing on char vs varchar