Re: how to alter/drop check contraint? - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: how to alter/drop check contraint?
Date
Msg-id Pine.BSF.4.21.0012201054060.82408-100000@megazone23.bigpanda.com
Whole thread Raw
In response to how to alter/drop check contraint?  (hubert depesz lubaczewski <depesz@depesz.pl>)
List pgsql-sql
There's no good way currently to drop the check constraint
really.  You probably can do it by removing the row for the
constraint from pg_relcheck and changing the pg_class row
for the table to have the correct number in relchecks.
In 7.1, you'd probably be able to add the check constraint
using ALTER TABLE ADD CONSTRAINT, but before that adding
the constraint would probably be difficult.

You're probably best off dumping the table, changing the
constraint and then restoring it.

[If you don't have any important data and you like the idea
of potentially causing yourself great deals of pain and suffering,
it might be possible to change the 10 to 20 by directly editing
the pg_relcheck row.  I have not attempted to do this though,
so I'm not sure it would work.]

Stephan Szabo
sszabo@bigpanda.com

On Wed, 20 Dec 2000, hubert depesz lubaczewski wrote:

> the subject should be self-explanatory, but:
> i have table:
> create table a (b text check (length(b)<10));
> and for some reason i want to drop this check or alter this to length(b)<20.
> how can i do so?
> 
> or maybe using trigger in plpgsql will be better?
> how to make trigger which will stop insert or update when something occurs?



pgsql-sql by date:

Previous
From: Artur Rataj
Date:
Subject: `~' operator and indices
Next
From: Kovacs Zoltan Sandor
Date:
Subject: Re: plpgsql ?