gpt4 book ai didi

php - MySql 外键查询错误

转载 作者:行者123 更新时间:2023-11-29 23:33:34 24 4
gpt4 key购买 nike

我正在mysql数据库中插入这个magento数据库表

CREATE TABLE `customer_address_entity` (
`entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity Id',
`entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity Type Id',
`attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Attribute Set Id',
`increment_id` varchar(50) DEFAULT NULL COMMENT 'Increment Id',
`parent_id` int(10) unsigned DEFAULT NULL COMMENT 'Parent Id',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Created At',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Updated At',
`is_active` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'Is Active',
PRIMARY KEY (`entity_id`),
KEY `IDX_CUSTOMER_ADDRESS_ENTITY_PARENT_ID` (`parent_id`),
CONSTRAINT `FK_CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID` FOREIGN KEY (`parent_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=96 DEFAULT CHARSET=utf8 COMMENT='Customer Address Entity';

但它显示错误消息

#1215 - 无法添加外键约束

如何修复此错误?

最佳答案

#1215 - Cannot add foreign key constraint

错误表明您的外键“customer_entity.entity_id”的引用存在问题

您应该检查是否:

  • “customer_entity”存在
  • “customer_entity.entity_id”存在
  • “customer_address_entity.parent_id”和“customer_entity.entity_id”的类型完全相同相同
  • 表“customer_address_entity”和“customer_entity”的字符集相同

无论如何,请提供有关数据库架构的更多信息,或者至少提供有关所涉及表的更多信息。

关于php - MySql 外键查询错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26465874/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com