From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: how to temporally disable foreign key constraint check
Date: Fri, 21 Oct 2011 19:04:14 +0200
Message-ID: <j7s8m5$nl0$1@dough.gmane.org> (raw)
In-Reply-To: <4EA17562.4030202@encs.concordia.ca>
References: <4EA17562.4030202@encs.concordia.ca>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: spam_eater@gmx.net
Subject: Re: how to temporally disable foreign key constraint check
In-Reply-To: <j7s8m5$nl0$1@dough.gmane.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox