Nit*_*hin 7 mysql mysqldump magento mysql-error-1452
我试图导入magento的sql转储以及一些产品数据,我得到这个外键约束错误:
`ERROR 1452 (23000) at line 231680: Cannot add or update a child row: a foreign key constraint fails:
`magento`.`#sql-b33_27`, CONSTRAINT `FK_CATALOG_COMPARE_ITEM_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID` FOREIGN KEY (`customer_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE CASCADE ON )`
Run Code Online (Sandbox Code Playgroud)
这是导致错误的sql代码:
--
-- Constraints for table `catalog_eav_attribute`
--
ALTER TABLE `catalog_eav_attribute`
ADD CONSTRAINT `FK_CATALOG_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID` FOREIGN KEY (`attribute_id`) REFERENCES `eav_attribute` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE;
Run Code Online (Sandbox Code Playgroud)
我对sql查询不是很满意.有人可以解释一下这个查询的作用并指导我解决这个问题吗?谢谢.
Ada*_*ger 17
您正在尝试添加记录catalog_eav_attribute,但在eav_attribute该匹配项中没有相应的记录attribute_id
如果您还要插入批量数据eav_attribute,我建议先执行此操作,然后在catalog_eav_attribute引用它之前需要外键之前将数据放在表中.
此文章讨论如何使用:
SET FOREIGN_KEY_CHECKS = 0;
--Do your update here
SET FOREIGN_KEY_CHECKS = 1;
Run Code Online (Sandbox Code Playgroud)
如果您无法更改插入数据的顺序.只需将所有内容插入数据库后,您就必须确保数据遵循外键,然后才能重新启用FOREIGN_KEY_CHECKS
| 归档时间: |
|
| 查看次数: |
15110 次 |
| 最近记录: |