1.現有從表score外鍵player_id與主表playerinfo主鍵id相關聯。
2.向從表格新增資料時,出現:
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (racesys
.score
, CONSTRAINT score_player_id_foreign
FOREIGN KEY (player_id
) REFERENCES playerinfo
(id
)) (SQL: insert into score
(id
, player_id
, node
, childnode
, time
) values (041be572-2ed5-3e01- ac2c-43bab35117e9, 00ec1635-0fd5-3481-a3d4-0afa4e8f66ea, 1, 1, 2007-05-23 14:38:26))"
3.
playerinfo主鍵id屬性
]
score外鍵player_id屬性
#問題:是什麼原因出現的外鍵約束失敗?如何解決?
在新增從表是外鍵在主表主鍵要有資料。