Re: how to alter/drop check contraint?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: hubert depesz lubaczewski <depesz(at)depesz(dot)pl>
Cc: PGSQL-SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: how to alter/drop check contraint?
Date: 2000-12-20 18:59:45
Message-ID: Pine.BSF.4.21.0012201054060.82408-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)bigpanda(dot)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?

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kovacs Zoltan Sandor 2000-12-20 20:51:26 Re: plpgsql ?
Previous Message Artur Rataj 2000-12-20 18:38:30 `~' operator and indices