Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 8F4D4B5DC6F for ; Fri, 21 Oct 2011 20:51:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 12308-02 for ; Fri, 21 Oct 2011 23:51:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-qy0-f174.google.com (mail-qy0-f174.google.com [209.85.216.174]) by mail.postgresql.org (Postfix) with ESMTP id 4EBC2B5DC6E for ; Fri, 21 Oct 2011 20:51:32 -0300 (ADT) Received: by qyk4 with SMTP id 4so1107264qyk.19 for ; Fri, 21 Oct 2011 16:51:32 -0700 (PDT) Received: by 10.229.64.153 with SMTP id e25mr3631186qci.74.1319241092098; Fri, 21 Oct 2011 16:51:32 -0700 (PDT) Received: from ayaki.localdomain (203-206-100-166.dyn.iinet.net.au. [203.206.100.166]) by mx.google.com with ESMTPS id f8sm16926713qap.15.2011.10.21.16.51.29 (version=SSLv3 cipher=OTHER); Fri, 21 Oct 2011 16:51:31 -0700 (PDT) Message-ID: <4EA2057F.3000002@ringerc.id.au> Date: Sat, 22 Oct 2011 07:51:27 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: emilu@encs.concordia.ca CC: pgsql-sql@postgresql.org Subject: Re: how to temporally disable foreign key constraint check References: <4EA17562.4030202@encs.concordia.ca> In-Reply-To: <4EA17562.4030202@encs.concordia.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201110/48 X-Sequence-Number: 35932 On 10/21/2011 09:36 PM, Emi Lu 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 If you really, really want to do this you can do it by disabling the triggers that enforce the checks on particular tables. This must be done table-by-table, there's no global way to do it. Use ALTER TABLE ... DISABLE TRIGGER to do it. See: http://www.postgresql.org/docs/current/static/sql-altertable.html -- Craig Ringer