Обсуждение: to suspend constraints

Поиск
Список
Период
Сортировка

to suspend constraints

От
"Jowisz"
Дата:
Hello,

Does anyone knows, is there any possibility to turn off temporarily (to
suspend) constraints checking? I couldn't find this in docs. Or maybe there
isn't way to do things like this...

Thanks in advance & greets
Adam


Re: to suspend constraints

От
Stephan Szabo
Дата:
On Wed, 26 Mar 2003, Jowisz wrote:

> Does anyone knows, is there any possibility to turn off temporarily (to
> suspend) constraints checking? I couldn't find this in docs. Or maybe there
> isn't way to do things like this...

Not in any easy user-accessable way that I know of (apart from dropping a
constraint and re-adding it).

If you're willing to go through some moderately painful changing of system
tables, you can stop foreign keys (and all user defined triggers) by
setting reltriggers to 0 in pg_class, but you have to be careful to set it
back to the correct value.  You can (at least in current sources) do
something similar for check constraints with relchecks AFAICS.  NOT NULL
can be controlled with attnotnull in the pg_attribute row for the
particular attribute.  I don't know of a reasonable way to turn off unique
(flipping indisunique in the pg_index row seems to not take effect
immediately if the index has been used in your session, and I'm really not
sure it's safe in any case).