删除索引时出现MySQL错误(errno 150) [英] MySQL Error when dropping index (errno 150)
问题描述
删除外键索引时遇到问题,我总是遇到相同的错误
I've got problem with dropping foreign key index, I always get the same error
ALTER TABLE `comments` DROP INDEX `id_user`
输出
1025 - Error on rename of './postuj_cz1/#sql-d834_a0c704'
to './postuj_cz1/comments' (errno: 150)
另一个表上的id_user
是简单的主键索引.
The id_user
on the other table is simple primary key index.
我正在使用MySQL 5.0.85版
I'm using MySQL version 5.0.85
推荐答案
According to this link, the error relates to the definition of the primary key field. The error isn't about the foreign key index.
检查COMMENTS
表的主键,以确保它没有UNSIGNED
关键字,而COMMENTS.id_user
外键具有UNSIGNED关键字.此关键字引起了问题-字段类型不一致.
Check the primary key for the COMMENTS
table to make sure it does not have the UNSIGNED
keyword while the COMMENTS.id_user
foreign key had the UNSIGNED keyword. This keyword was causing the problem - inconsistent type of field.
要修复,请将UNSIGNED
关键字添加到COMMENTS
表的主键定义中.或从外键定义中删除UNSIGNED
关键字...
To fix, add the UNSIGNED
keyword to the primary key definition for the COMMENTS
table. Or remove the UNSIGNED
keyword from the foreign key definition...
这篇关于删除索引时出现MySQL错误(errno 150)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!