How to temporarily disable a table's FK constraints?

Поиск
Список
Период
Сортировка
От Kynn Jones
Тема How to temporarily disable a table's FK constraints?
Дата
Msg-id c2350ba40711050850u7c0a5644n63c75446585bc449@mail.gmail.com
обсуждение исходный текст
Ответы Re: How to temporarily disable a table's FK constraints?  (Erik Jones <erik@myemma.com>)
Re: How to temporarily disable a table's FK constraints?  (Ron Johnson <ron.l.johnson@cox.net>)
Re: How to temporarily disable a table's FK constraints?  (andy <andy@squeakycode.net>)
Список pgsql-general
Hi, everyone.

Is there a standard way to disable a table foreign-key constraint temporarily?

I thought that this would be a fairly common thing to want to do, but
I only found this snippet online:

-- to disable
UPDATE pg_class SET reltriggers=0 WHERE relname = 'your_table';

-- to re-enable
UPDATE pg_class SET reltriggers = count( * )
  FROM pg_trigger WHERE pg_class.oid=tgrelid AND relname = 'your_table';

and it appears that one needs to be root to execute these statements.

Is there any other way for non-root users?

TIA!

kj

В списке pgsql-general по дате отправления:

Предыдущее
От: Lincoln Yeoh
Дата:
Сообщение: Re: COPY ... FROM and index usage
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Restore a database