Re: Suspend Referential Integrity?

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: Jim Jarrett <jarrett(at)rpa(dot)net>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Suspend Referential Integrity?
Date: 2005-08-15 17:38:47
Message-ID: BF264B67.C6C7%sdavis2@mail.nih.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 8/15/05 1:31 PM, "Bruno Wolff III" <bruno(at)wolff(dot)to> wrote:

> On Mon, Aug 08, 2005 at 09:49:38 -0400,
> Jim Jarrett <jarrett(at)rpa(dot)net> wrote:
>> I'm trying to load a database ported from Oracle. The commands I was given
>> to
>> load data into the table are in alphabetical order; when I run them, I get
>> errors because I'm violating RI rules (eg. table "CUSTOMER" has RI to
>> "SOURCE",
>> but CUSTOMER attempts to load before SOURCE).
>>
>> Certainly, I could try to reorder the load statements, but that would be just
>> a
>> huge PITA. Is there a way to temporarily suspend RI on a PostgreSQL
>> database/schema, and then "fix it later?" Either delete the rows that break
>> rules or add rows to fix the violations?
>
> For an initial load the best thing is probably to not include the foreign key
> constraints in the initial table definitions and add them at the end of the
> load using alter table commands.

As an additional point, sometime I find it helps to do an initial load into
a different schema (same database) and then use a sql script/function to do
"cleanup" into the final schema with RI in place.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andrej Ricnik-Bay 2005-08-15 18:35:24 "external" variables and triggers
Previous Message Bruno Wolff III 2005-08-15 17:31:19 Re: Suspend Referential Integrity?