Search Postgresql Archives

Re: Disability the trigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/16/06, Tomi NA <hefest@xxxxxxxxx> wrote:
>
>
> On 3/13/06, Claudio Tognolo <claudio.tognolo@xxxxxxxxx> wrote:
> >
> > I can disable the Trigger?
> >
>
> I'd like to know how this could be done, as well. What I really need is a
> hold-off-all-triggers-untill-I-tell-you-to command, but
> hey, making a trigger just not fire and vice versa would also be nice. :)
>
> Tomislav
>
You can mark triggers as DEFERRABLE and optionally INITIALLY DEFERRED
which will make them hold off on firing until the end of the
transaction, or you can actually turn off triggers with something like
this.

UPDATE "pg_class" SET "reltriggers" = 0 WHERE "relname" = 'tablename';

and turn them back on like so

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

Of course, all that is best done inside an explicit transaction.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux