Re: Changing column constraints?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: <hjholland(at)gmx(dot)net>, pgsql sql-list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Changing column constraints?
Date: 2002-02-21 19:52:05
Message-ID: 20020221114936.W21441-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Thu, 21 Feb 2002, Josh Berkus wrote:

> Henry,
>
> > If I have a column constraint:
> > addr_type char( 10 ) default 'street'
> > CHECK( addr_type = 'street' || addr_type = 'pobox' ),
> > in a table, how can I add another choice to the list after I've
> > already
> > entered data into the table?
>
> Three options:
>
> One, drop and rebuild the table with the constraint modified. Sorry,
> but until we have ALTER CONSTRAINT implemented, this is the only
> simple way to modify and exisiting constraint.

Umm... on 7.2 you should be able to drop the existing constraint
and add a new one. If you don't name the constraint you have to
find the internally generated name for the constraint from pg_relcheck
however.

> Three, drop and re-build the table, and this time do it right: have
> column addr_type reference another table called "addr_types" that list
> the acceptable type values. Then use a foriegn key to enforce this.

This is probably happier in any case...

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Emberson 2002-02-21 20:17:08 Finding matching columns from two tables
Previous Message Hunter, Ray 2002-02-21 19:30:11 Re: current connections and queries