Skip site navigation (1) Skip section navigation (2)

Re: CHECK col A not NULL if col B='x'

From: T E Schmitz <mailreg(at)numerixtechnology(dot)de>
To:
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: CHECK col A not NULL if col B='x'
Date: 2004-09-28 15:01:38
Message-ID: 41597CD2.1030602@numerixtechnology.de (view raw or flat)
Thread:
Lists: pgsql-sql
Hello again,


Martin Marques wrote:

> El Mar 28 Sep 2004 11:02, T E Schmitz escribiĆ³:
> 
>>Is it possible to set up a table CHECK, which ensures that column A is
>>NOT NULL if column B = 'x' ?
> 
> 
> CONSTRAINT somename CHECK (B <> 'x' OR A IS NOT NULL)

I noticed a table constraint can be added via ALTER TABLE. Is it correct 
that a column constraint cannot be added via the ALTER TABLE other than 
by dropping and adding the column? (I am using psql 7.4.2.)

-- 


Regards/GruƟ,

Tarlika Elisabeth Schmitz

In response to

Responses

pgsql-sql by date

Next:From: Paul ThomasDate: 2004-09-28 20:39:00
Subject: Re: Doubt
Previous:From: T E SchmitzDate: 2004-09-28 14:38:21
Subject: Re: CHECK col A not NULL if col B='x'

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group