Re: ENABLE / DISABLE ALL TRIGGERS IN DATABASE

From: Terry Lee Tucker <terry(at)chosen-ones(dot)org>
To: "PostgreSQL" <pgsql-general(at)postgresql(dot)org>
Subject: Re: ENABLE / DISABLE ALL TRIGGERS IN DATABASE
Date: 2008-08-27 09:36:44
Message-ID: 200808270536.45010.terry@chosen-ones.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 27 August 2008 04:24, Teemu Juntunen wrote:
> Hi,
>
> I think this has been asked before, but I can't find the answer from arcive
> nor google. How to disable/enable all the riggers in a database? I have
> problem with disabled triggers after database restore. If there is no
> simple way, could this be made in a function where you find the table names
> and construct the needed commands in strings. If so, how to get all the
> tablenames from database?
>
> Best regards and thanks!
> Teemu Juntunen

You can accomplish this by manipulating the run time parameter,
session_replication_role. For example, from within your psql session:
SET SESSION session_replication_role = replica;
This will prevent all triggers from firing for the entire session except those
defined as "replica". We use this all the time.

HTH...
--
Terry Lee Tucker
Turbo's IT Manager
Turbo, division of Ozburn-Hessey Logistics
2251 Jesse Jewell Pkwy NE
Gainesville, GA 30501
Tel: (336) 372-6812 Fax: (336) 372-6812 Cell: (336) 404-6987
terry(at)turbocorp(dot)com
www.turbocorp.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2008-08-27 10:44:20 Re: update and group by/aggregate
Previous Message Teemu Juntunen 2008-08-27 09:21:12 Re: ENABLE / DISABLE ALL TRIGGERS IN DATABASE