Skip site navigation (1) Skip section navigation (2)

Re: Find all foreign keys and dropping them from a script.

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Robert Landsmeer <r(dot)landsmeer(at)wis(dot)nl>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Find all foreign keys and dropping them from a script.
Date: 2006-04-18 14:52:55
Message-ID: 20060418145254.GA82223@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-novice
On Tue, Apr 18, 2006 at 04:05:48PM +0200, Robert Landsmeer wrote:
> To update the database we have a script that will execute all the data
> updates of the product. Since the updater isn't aware of what updates
> need to be done before other updates FK-wise we get all kinds of errors
> about incorrect data, and the script fails.  So we want to drop all
> foreign keys, insert a lot of data, and then re-add all foreign keys.

Are the updates all done in the same transaction?  If so then you
might be able to use deferrable foreign key constraints.  Search
the following documentation for the words "DEFERRABLE" and "DEFERRED":

http://www.postgresql.org/docs/8.1/interactive/sql-createtable.html
http://www.postgresql.org/docs/8.1/interactive/sql-set-constraints.html

-- 
Michael Fuhr

In response to

pgsql-novice by date

Next:From: Robert LandsmeerDate: 2006-04-18 15:49:08
Subject: Re: Find all foreign keys and dropping them from a script.
Previous:From: Florian ReiserDate: 2006-04-18 14:13:20
Subject: Re: The COPY command and csv files

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group