Re: How to temporarily disable a table's FK constraints? - Mailing list pgsql-general

From Kynn Jones
Subject Re: How to temporarily disable a table's FK constraints?
Date
Msg-id c2350ba40711050952y1c9e68ccs3c25850056dff522@mail.gmail.com
Whole thread Raw
In response to Re: How to temporarily disable a table's FK constraints?  (Erik Jones <erik@myemma.com>)
Responses Re: How to temporarily disable a table's FK constraints?  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Re: How to temporarily disable a table's FK constraints?  (Erik Jones <erik@myemma.com>)
Re: How to temporarily disable a table's FK constraints?  (Sam Mason <sam@samason.me.uk>)
List pgsql-general
On 11/5/07, Erik Jones <erik@myemma.com> wrote:

> On Nov 5, 2007, at 10:50 AM, Kynn Jones wrote:
> > Is there a standard way to disable a table foreign-key constraint
> > temporarily?
> >
> > I thought that this would be a fairly common thing to want to do...

> Can you explain what it is you're actually trying to do?  As in,
> what's your use case for needing to do this?

A Perl script that needs to update a referring table with many new
entries before knowing the foreign keys for each new record.  (I
described a similar situation in a recent post, Subject: Populating
large DB from Perl script.)

Also, Ron, the *owner* of a table is not a "regular user" as far as
that table is concern.  That user has special privileges, including
that of dropping constraints.  What I seek to do is no greater a
violation of the idea of enforcing relational integrity than is the
ability to drop constraints altogether.

BTW, I realize that I can just drop and reinstate constraints, but
from the point of view of writing a Perl script to do all this, it
would be much easier if I could just disable temporarily all the FK
constraints on a table.

kj

pgsql-general by date:

Previous
From: Keith Carr
Date:
Subject: Bitemporal sequenced unique constraint (function/trigger)
Next
From: David Fetter
Date:
Subject: Re: Problems with PostgreSQL DBI-Link / DBD-ODBC