2013-03-28 29 views
0

我有這樣的表:轉換表發動機的MyISAM到INNODB錯誤號: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! 

任何想法高度讚賞。謝謝。

回答

0

當外鍵的列與指向的列不完全匹配時,我主要遇到該錯誤。 (類型,符號/無符號)

編輯讀您的文章第二次之後,我認出了真正的錯誤:你interlocuteurs表需要與id_interlocuteur作爲第一列的索引。

+0

謝謝!我的問題是通過索引id_interlocuteur解決的。 – kurtec