From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
---|---|
To: | pgsql-de-allgemein(at)postgresql(dot)org |
Subject: | Re: Ueberpruefung von FOREIGN_KEYS abschalten |
Date: | 2008-11-29 08:24:06 |
Message-ID: | 20081129082405.GA7263@tux |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-de-allgemein |
Thomas Steinbach <steinbach(at)gmx-topmail(dot)de> schrieb:
> Hallo,
>
> gibt es bei PostgreSQL sowas wie ein
>
> "SET FOREIGN_KEY_CHECKS=0;"
>
> wie bei MySQL?
Du kannst RI-Constraints deferrable setzen:
test=# create table m (id int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "m_pkey"
for table "m"
CREATE TABLE
Zeit: 28,950 ms
test=*# create table s (f int references m deferrable initially
deferred);
CREATE TABLE
Zeit: 2848,866 ms
test=*#
test=*#
test=*#
test=*# insert into s values (1);
INSERT 0 1
Zeit: 0,375 ms
test=*# commit;
ERROR: insert or update on table "s" violates foreign key constraint "s_f_fkey"
DETAIL: Key (f)=(1) is not present in table "m".
Dann schlagen diese erst beim COMMIT zu.
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
From | Date | Subject | |
---|---|---|---|
Next Message | Albe Laurenz | 2008-12-01 10:49:34 | Re: Ueberpruefung von FOREIGN_KEYS abschalten |
Previous Message | Thomas Steinbach | 2008-11-24 11:55:29 | Ueberpruefung von FOREIGN_KEYS abschalten |