Re: Copy/foreign key contraints

From: Jan Poslusny <pajout(at)gingerall(dot)cz>
To: ken(at)perfect-image(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Copy/foreign key contraints
Date: 2002-12-13 15:46:35
Message-ID: 3DFA00DB.4020609@gingerall.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

explore options and output of pgdump, it must do it correctly

Ken Godee wrote:
> Being fairly new to postgres I'm trying to find my way
> around this, did some searching and see this has come
> up quite a few times, but..........
>
> table 1: customer.custid primary key
> table 2: transx.custid foreign key
>
> When using COPY to import data I received;
>
> "<unnamed>referential integerity violation-key referenced from
> table transx not found in customer" (fairly vague statement)
>
> I'm sure many know where this is going, but I'll still explain
> what I've tried so far.......
>
> Then created a copy/temp table of transx with no constraints
> and COPY'ed data into it, ran some "where not exists" statements
> against the customer.custid and found no unmatched
> primary/foreign keys. Tried to do an INSERT from the temp table
> into the transx table and still got the referential integerity violation.
> At this point I'm presuming that my data's ok, so now what.....
>
> Drop the foreign key, import data, then add foreign key back?
> But what if there is a real "referential integerity violation"?
> How are others dealing with this or am I just doing something
> wrong?
>
> postgres 7.2.1 / Rh7.3
>
> Also as a side note;
> It would be nice while data import if it
> would just create an exception file and continue the import
> of data with a way to see/count exceptions at the end of import
> with a choice to then process the file and save the exceptions.
>
> Sorry to ramble........
>
> Ken
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2002-12-13 16:00:14 Re: INDEX suggestion needed
Previous Message Thomas Beutin 2002-12-13 15:41:38 Re: INDEX suggestion needed