繁体   English   中英

将表引擎MyISAM转换为INNODB errno:150

[英]Convert table engine MyISAM to INNODB errno: 150

我有这张桌子:

CREATE TABLE IF NOT EXISTS `interlocuteur_fonction` (
  `id_interlocuteur_fonction` int(11) NOT NULL AUTO_INCREMENT,
  `id_interlocuteur` int(11) NOT NULL,
  `id_fonction_interlocuteur` int(11) NOT NULL,
  `defaut` varchar(1) NOT NULL,
  PRIMARY KEY (`id_interlocuteur_fonction`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2227 ;

当我尝试这个查询:

ALTER TABLE `interlocuteur_fonction` engine=InnoDB

我收到一条错误消息:

#1025 - Error on rename of './preprod_test/#sql-457_210' to './preprod_test/interlocuteur_fonction' (errno: 150)

SHOW ENGINE INNODB STATUS的输出:

LATEST FOREIGN KEY ERROR
------------------------
130328 12:00:36 Error in foreign key constraint of table 
ilang2_test/interlocuteur_fonction:
there is no index in the table which would contain
the columns as the first columns, or the data types in the
table do not match the ones in the referenced table
or one of the ON ... SET NULL columns is declared NOT NULL. 
Constraint:
,
CONSTRAINT "interlocuteur_fonction_id_interlocuteur_id_interlocuteur" FOREIGN KEY 
("id_interlocuteur") REFERENCES "interlocuteurs" ("id_interlocuteur")
InnoDB: Renaming table `preprod_test`.`#sql-457_1bb` to 
`preprod_test`.`interlocuteur_fonction` failed!

任何想法都受到高度赞赏。 谢谢。

我主要在外键的列与它所指向的列不完全匹配时遇到了该错误。 (类型,有符号/无符号)

编辑第二次阅读您的文章后,我发现了真正的错误:您的interlocuteurs表需要一个索引,其中id_interlocuteur为第一列。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM