gpt4 book ai didi

MySQL: 无法创建表 (errno: 150)

转载 作者:行者123 更新时间:2023-11-30 22:31:59 24 4
gpt4 key购买 nike

我正在尝试导入 .sql 文件,但创建表失败。

这是失败的查询:

CREATE TABLE `data` (
`id` int(10) unsigned NOT NULL,
`name` varchar(100) NOT NULL,
`value` varchar(15) NOT NULL,
UNIQUE KEY `id` (`id`,`name`),
CONSTRAINT `data_ibfk_1` FOREIGN KEY (`id`) REFERENCES `keywords` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

我从同一个数据库导出了 .sql,删除了所有表,现在我尝试导入它,为什么会失败?

MySQL: Can't create table './dbname/data.frm' (errno: 150)

最佳答案

来自MySQL - FOREIGN KEY Constraints Documentation :

If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the correct column names and types, and it must have indexes on the referenced keys, as stated earlier. If these are not satisfied, MySQL returns Error 1005 and refers to Error 150 in the error message, which means that a foreign key constraint was not correctly formed. Similarly, if an ALTER TABLE fails due to Error 150, this means that a foreign key definition would be incorrectly formed for the altered table.

关于MySQL: 无法创建表 (errno: 150),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33635100/

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