Re: how to temporally disable foreign key constraint check - Mailing list pgsql-sql

From Thomas Kellerer
Subject Re: how to temporally disable foreign key constraint check
Date
Msg-id j7s8m5$nl0$1@dough.gmane.org
Whole thread Raw
In response to how to temporally disable foreign key constraint check  (Emi Lu <emilu@encs.concordia.ca>)
List pgsql-sql
Emi Lu wrote on 21.10.2011 15:36:
> 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
>
> Thanks a lot!
> Emi
>
You can define the FKs as "DEFERRABLE INITIALLY IMMEDIATE".

Then at the start of your transaction you can defer constraint checking until you commit everything using:

SET CONSTRAINTS ALL DEFERRED;

Thomas




pgsql-sql by date:

Previous
From: Emi Lu
Date:
Subject: Re: how to temporally disable foreign key constraint check
Next
From: Craig Ringer
Date:
Subject: Re: how to temporally disable foreign key constraint check