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

时间:2021-07-07 20:09:47

I have this table :

我有这张桌子:

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 ;

When i try this query :

当我尝试这个查询时:

ALTER TABLE `interlocuteur_fonction` engine=InnoDB

I received an error message:

我收到了一条错误消息:

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

Output of SHOW ENGINE INNODB STATUS:

SHOW ENGINE INNODB状态的输出:

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!

Any idea is highly appreciated. Thanks.

任何想法都非常感谢。谢谢。

1 个解决方案

#1


0  

I encountered that error mostly when the column of the foreign key doesn't exactly match the column where it is pointing to. (Type, signed/unsigned)

我遇到了这个错误,主要是当外键的列与它所指向的列不完全匹配时。 (类型,签名/未签名)

EDIT After reading your post a second time, I recognized the real error: your interlocuteurs table needs an index with id_interlocuteur as first column.

编辑在第二次阅读你的帖子后,我发现了真正的错误:你的interlocuteurs表需要一个id_interlocuteur作为第一列的索引。

#1


0  

I encountered that error mostly when the column of the foreign key doesn't exactly match the column where it is pointing to. (Type, signed/unsigned)

我遇到了这个错误,主要是当外键的列与它所指向的列不完全匹配时。 (类型,签名/未签名)

EDIT After reading your post a second time, I recognized the real error: your interlocuteurs table needs an index with id_interlocuteur as first column.

编辑在第二次阅读你的帖子后,我发现了真正的错误:你的interlocuteurs表需要一个id_interlocuteur作为第一列的索引。