Hallo,
ich hab folgende DB-Struktur
dw_karte
-------------------
karte_x
karte_y
tile_id
dw_spieler
-------------------
spieler_id
karte_x > Fremdschlüssel auf dw_karte/kate_x und karte_y
karte_y |
Wenn ich jetzt ein TRUNCATE TABLE dw_karte aussführen, erhalte ich folgende Fehlermeldung:
Query failed: ERROR: cannot truncate a table referenced in a foreign key constraint DETAIL: Table "dw_spieler" references "dw_karte" via foreign key constraint "karte_xy". HINT: Truncate table "dw_spieler" at the same time. in /home/5458/www.dualwar.de/class/db.class.php on line 27
ERROR: cannot truncate a table referenced in a foreign key constraint DETAIL: Table "dw_spieler" references "dw_karte" via foreign key constraint "karte_xy". HINT: Truncate table "dw_spieler" at the same time.
Ich weiß, dass es am FK liegt, aber nicht wieso und wo genau das Problem liegt. Definition des FK:
Code:
ALTER TABLE dw_spieler
ADD CONSTRAINT karte_xy FOREIGN KEY (karte_x, karte_y)
REFERENCES dw_karte (karte_x, karte_y) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION; Ziel soll es sein, dass ich in die Spieler-Tabelle keine ungültigen Karten-Werte eintragen kann. Danke für euere Hilfe!
Lesezeichen