Re: problem with foreign keys + data-only backup - Mailing list pgsql-general

From Markus Mehrwald
Subject Re: problem with foreign keys + data-only backup
Date
Msg-id 48AEC3BB.7080107@ira.uka.de
Whole thread Raw
In response to Re: problem with foreign keys + data-only backup  (Richard Huxton <dev@archonet.com>)
Responses Re: problem with foreign keys + data-only backup
List pgsql-general
Hi,

I do not think this will work. As far as I know foreign key checks are
not triggers. Postgres is very strict with things concerning referential
integrity so you cannot turn them off.

Maybe it will help to use "--orig-order" for creating the dump.

Markus


Richard Huxton schrieb:
> Peter Billen wrote:
>> Hi all,
>>
>> I have a problem with foreign keys and data-only (no schema) backup. I
>> have a simple table node (pseudo-SQL):
>
>> When I do a data-only backup, the backup file contains following two lines:
>>
>> INSERT INTO NODE (node_id, parent_node_id) VALUES (2, 1);
>> INSERT INTO NODE (node_id, parent_node_id) VALUES (1, NULL);
>>
>> Restoring the backup file into another database ofcourse fails, because
>> the parent_node_id (1) in the first INSERT statement refers to an
>> unknown (to be added) node (in the second statement).
>>
>> How do I make sure my backup orders the insert statements in a logical
>> order?
>
> You don't. You might find --disable-triggers useful though. See the
> pg_restore documentation for details.
>

--
Dipl.-Inform. Med. Markus Mehrwald
Institut für Prozessrechentechnik, Automation und Robotik
Medizin-Gruppe
Universität Karlsruhe (TH)
Gebäude 40.28, Zimmer 110
Engler-Bunte-Ring 8
76131 Karlsruhe

Fon: +49 (721) 608-7113
Fax: +49 (721) 608-7141

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: problem with foreign keys + data-only backup
Next
From: Sam Mason
Date:
Subject: Re: SERIAL datatype