0
在phpmyadmin中創建2個表時,我收到了這樣的錯誤。不能在phpmyadmin中添加外鍵約束
MySQL表示:文件
#1215 - 不能添加外鍵約束
我的表結構
CREATE TABLE `iwd_storelocator_manufacturer` (
`entity_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` varchar(255) NOT NULL ,
`code` varchar(255) NOT NULL ,
`grayscale_image` varchar(255) NULL ,
`color_image` varchar(255) NULL ,
PRIMARY KEY (`entity_id`)
);
CREATE TABLE `iwd_storelocator_manufacturer_to_store` (
`manufacturer_id` int(11) UNSIGNED NOT NULL ,
`store_id` int(11) NOT NULL ,
`preferred` int NULL ,
PRIMARY KEY (`manufacturer_id`, `store_id`),
FOREIGN KEY (`store_id`) REFERENCES `iwd_storelocator_store` (`store_id`) ON DELETE RESTRICT ON UPDATE CASCADE,
FOREIGN KEY (`manufacturer_id`) REFERENCES `iwd_storelocator_manufacturer` (`entity_id`) ON DELETE RESTRICT ON UPDATE CASCADE
);
你能告訴我什麼是它的問題?
這是我iwd_storelocator_store表
我已經成功創建了這些表,但沒有FK到iwd_storelocator_store。也許這張桌子是問題的原因? –
「iwd_storelocator_store」表的結構如何? – 1000111
我給出了iwd_storelocator_store表結構。 – Sheen