laravel foreign key constraint failed
高洛峰
高洛峰 2017-05-16 16:46:55
0
1
849

1. The existing slave table score foreign key player_id is associated with the main table playerinfo primary key id.
2. When adding data to the slave table, an error occurred:
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 primary key id attribute

]

score foreign key player_id attribute

Question: What is the reason for the foreign key constraint failure? How to solve?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
曾经蜡笔没有小新

When adding the slave table, the foreign key must have data in the primary key of the master table.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!