Re: Changing column constraints?

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: hjholland(at)gmx(dot)net, pgsql sql-list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Changing column constraints?
Date: 2002-02-21 19:07:44
Message-ID: web-699705@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

Two, mess with system tables to alter the constraint. I do not
reccomend this.

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.

-Josh Berkus

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Hunter, Ray 2002-02-21 19:30:11 Re: current connections and queries
Previous Message Josh Berkus 2002-02-21 19:03:00 Re: Money type and kylix