Re: Modifying check constraints

From: "Thalis A(dot) Kalfigopoulos" <thalis(at)cs(dot)pitt(dot)edu>
To: Paulo Jan <admin(at)mail(dot)ddnet(dot)es>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Modifying check constraints
Date: 2001-11-14 18:47:32
Message-ID: Pine.LNX.4.21.0111141343150.20050-100000@aluminum.cs.pitt.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 14 Nov 2001, Paulo Jan wrote:

> Hi all:
>
> Let's suppose I create a table with a CHECK constraint, like:
>
> CREATE TABLE blabla (id int, tipo varchar(8),
> CHECK tipo IN ('tipo1', 'tipo2', 'tipo3'))
>
> Can I change the CHECK constraint afterwards? For example, can I
> add another value that "tipo" can have, or I'd have to recreate the
> table?

Add another constraint with
ALTER TABLE lala ADD CONSTRAINT lalaCheck2 CHECK tipo in ('t1','t2','t3','t4');

The new check will be in effect along with the old one. Make sure the check constraints don't allow disjoint sets of values cause then you won't be able to add anything to the table.

cheers,
thalis

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jason Earl 2001-11-14 19:07:05 Re: Modifying check constraints
Previous Message Bryan White 2001-11-14 18:45:15 Re: multiple hard disk