這是我報名參加了表MySQL錯誤1452(23000)不能添加或更新子行的外鍵約束失敗
mysql> create table A6M351kjp.Claim (ClaimID INT (10) NOT NULL, VIN INT (10) NOT NULL, ClaimDate DateTime Null, ClaimStatus VarChar(45) Null, Primary Key (ClaimID));
添加外鍵在這裏
mysql> alter table A6M351kjp.Claim add foreign key (VIN) references Car(VIN);
輸入數據
mysql> insert into A6M351kjp.Claim (ClaimID, VIN, ClaimDate, ClaimStatus) values (101, 901, '2014-01-01', 'Open');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`A6M351kjp`.`Claim`, CONSTRAINT `Claim_ibfk_1` FOREIGN KEY (`VIN`) REFERENCES `Car` (`VIN`))
什麼是這個錯誤的原因,我該如何解決這個問題?
謝謝
這一切都在錯誤消息中 - 外鍵約束失敗。 – zerkms 2014-12-04 07:17:46