[英]MySql query error for foreign key
I am inserting this magento database table in mysql database 我在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';
But it is displaying error message 但它显示错误消息
#1215 - Cannot add foreign key constraint #1215-无法添加外键约束
How can I fix this error ? 如何解决此错误?
#1215 - Cannot add foreign key constraint
Error indicates that there is a problem with the reference of your foreign key 'customer_entity.entity_id' 错误表明您的外键'customer_entity.entity_id'的引用存在问题
You should check if: 您应该检查是否:
In any case, provide more information about your database's schema or at least more information for the involved tables. 无论如何,请提供有关数据库架构的更多信息,或者至少提供有关表的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.