Re: Temporally disabled foreign key constraint check?

From: raghu ram <raghuchennuru(at)gmail(dot)com>
To: emilu(at)encs(dot)concordia(dot)ca
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Temporally disabled foreign key constraint check?
Date: 2011-10-21 15:12:56
Message-ID: CALnrrJS9Lv-6fa5Z43CJcaoQJ6ybUMuCiDatTpCnRnpHckBadA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 21, 2011 at 8:33 PM, Emi Lu <emilu(at)encs(dot)concordia(dot)ca> wrote:

> Good morning,
>
>
> Is there a way to temporally disabled foreign key constraints something
> like:
>
> SET FOREIGN_KEY_CHECKS=0
>
> When population is done, will set FOREIGN_KEY_CHECKS=1
>
>
You can disable *triggers* on a table (which will disable all the FK
constraints, but not things like 'not nul' or 'unique').

For Disable:

update pg_class set reltriggers=0 where relname = 'TEST';

For Enable:

update pg_class set reltriggers = count(*) from pg_trigger where
pg_class.oid=tgrelid and relname='TEST';

--Raghu

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2011-10-21 15:22:31 Re: Temporally disabled foreign key constraint check?
Previous Message Emi Lu 2011-10-21 15:03:09 Temporally disabled foreign key constraint check?