pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: hjholland@gmx.net, pgsql sql-list <pgsql-sql@postgresql.org>
Subject: Re: Changing column constraints?
Date: Thu, 21 Feb 2002 11:07:44 -0800
Message-ID: <web-699705@davinci.ethosmedia.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0202211124350.1016-100000@st12.stats.ru.ac.za>

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
 



view thread (3+ messages)  latest in thread

Message-ID: <web-699705@davinci.ethosmedia.com>
Permalink:  ../web-699705@davinci.ethosmedia.com/
Also on:    postgresql.org/message-id/web-699705@davinci.ethosmedia.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com
  Subject: Re: Changing column constraints?
  In-Reply-To: <web-699705@davinci.ethosmedia.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox