pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to temporarily disable referntial integrity?
2+ messages / 2 participants
[nested] [flat]
* How to temporarily disable referntial integrity?
@ 2004-12-07 18:17 Ari Johannesson <arividar@simnet.is>
2004-12-11 18:21 ` Re: How to temporarily disable referntial integrity? Michael Fuhr <mike@fuhr.org>
0 siblings, 1 reply; 2+ messages in thread
From: Ari Johannesson @ 2004-12-07 18:17 UTC (permalink / raw)
To: pgsql-admin
I have data to import into a postgres database. The data is referentially
sound but during the insert it breaks som foreign-key constraints. Is there
a way to turn off the referential integrity during the insert?
Thanks,
Ari Johannesson
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: How to temporarily disable referntial integrity?
2004-12-07 18:17 How to temporarily disable referntial integrity? Ari Johannesson <arividar@simnet.is>
@ 2004-12-11 18:21 ` Michael Fuhr <mike@fuhr.org>
0 siblings, 0 replies; 2+ messages in thread
From: Michael Fuhr @ 2004-12-11 18:21 UTC (permalink / raw)
To: Ari Johannesson <arividar@simnet.is>; +Cc: pgsql-admin
On Tue, Dec 07, 2004 at 06:17:48PM -0000, Ari Johannesson wrote:
> I have data to import into a postgres database. The data is referentially
> sound but during the insert it breaks som foreign-key constraints. Is there
> a way to turn off the referential integrity during the insert?
You could make the foreign key constraints deferrable and use SET
CONSTRAINTS to defer all or some of them.
CREATE TABLE foo (id INTEGER PRIMARY KEY);
CREATE TABLE bar (id INTEGER REFERENCES foo DEFERRABLE);
BEGIN;
SET CONSTRAINTS bar_id_fkey DEFERRED;
INSERT INTO bar VALUES (1);
INSERT INTO foo VALUES (1);
COMMIT;
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-12-11 18:21 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-12-07 18:17 How to temporarily disable referntial integrity? Ari Johannesson <arividar@simnet.is>
2004-12-11 18:21 ` Michael Fuhr <mike@fuhr.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox