how do I DROP this CONSTRAINT?

Started by Alexey Borzovabout 25 years ago2 messagesgeneral
Jump to latest
#1Alexey Borzov
borz_off@rdw.ru

Greetings!

Well, here is the problem:
A "production" table has a CHECK left from "development" days and I need
to delete it. It is not a foreign key, just a silly limit on a field's
value.
Of course, I can perform a CREATE/DROP/RENAME ritual, but would
rather not, as the table is large and it is referenced by other
tables.
I browsed the manual and found that CHECK's are kept in pg_relcheck
and their count in pg_class.

So, the question:
Can I just delete the record in pg_relcheck, decrement the counter
in pg_class and enjoy the results or will it have undesirable
side-effects?

--
Yours, Alexey V. Borzov, Webmaster of RDW.ru

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alexey Borzov (#1)
Re: how do I DROP this CONSTRAINT?

Alexey Borzov <borz_off@rdw.ru> writes:

Can I just delete the record in pg_relcheck, decrement the counter
in pg_class and enjoy the results or will it have undesirable
side-effects?

Should work; be careful to do the pg_class change last, else you'll
likely get inconsistency complaints. IIRC, the pg_class change will
trigger relation-cache reload for the table, and the indicated number
of records had better match pg_relcache when that happens.

regards, tom lane