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属性
问题:是什么原因出现的外键约束失败?如何解决?
在添加从表是外键在主表主键要有数据。