1452 - Can't write; duplicate in table '#sql-3e89_a4和1452 - Canot add or update a child row:解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。如若转载,请注明出处! https://blog.csdn.net/Homewm/article/details/81632756

mysql设置外键时遇到的两个问题:

(1)1452 - Can't write; duplicate in table '#sql-3e89_a4

(2)1452 - Canot add or update a child row: a foreign key constrain fails

解决过程如下:

(1)1452 - Can't write; duplicate in table '#sql-3e89_a4

原因:外键名称重复,重新定义外键名称即可,虽然不是同一个表中定义外键,但是仍然不能定义相同的外键。

参考连接:https://blog.csdn.net/efine_dxq/article/details/65937452

(2)1452 - Canot add or update a child row: a foreign key constrain fails

原因: 设置的外键和对应的另一个表的主键值不匹配。 解决方法: 找出不匹配的值修改。 或者清空两表数据。

参考链接:https://blog.csdn.net/qq_29405421/article/details/53907702

猜你喜欢

转载自blog.csdn.net/Homewm/article/details/81632756