删除索引时出现MySQL错误(errno 150) [英] MySQL Error when dropping index (errno 150)

查看:297
本文介绍了删除索引时出现MySQL错误(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆