Обсуждение: Disable Trigger

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

Disable Trigger

От
Charles Haron
Дата:
Is there a way to temporarily disable a trigger without dropping and
re-adding it?

Thanks,
Chuck


Re: Disable Trigger

От
Bruce Momjian
Дата:
Charles Haron wrote:
> Is there a way to temporarily disable a trigger without dropping and
> re-adding it?

You can update the sytem tables by setting the number of triggers to
zero on the table. See the PostgreSQL cookbook for examples.  We have a
TODO item to get this implemented cleanly.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Disable Trigger

От
CoL
Дата:
hi,

Charles Haron wrote, On 3/23/2004 21:48:

> Is there a way to temporarily disable a trigger without dropping and
> re-adding it?

if you ever use dump:
pg_dump --disable-triggers ...


off:
UPDATE pg_catalog.pg_class SET reltriggers = 0 WHERE oid =
'tablename'::pg_catalog.regclass;

on:
UPDATE pg_catalog.pg_class SET reltriggers = (SELECT pg_catalog.count(*)
FROM pg_catalog.pg_trigger where pg_class.oid = tgrelid) WHERE oid =
'tablename'::pg_catalog.regclass;

C.