MySQL 删除索引时出错(errno 150)

发布于 2024-08-05 10:23:06 字数 319 浏览 1 评论 0原文

我在删除外键索引时遇到问题,总是得到相同的错误

 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 是简单的主键索引。

我正在使用 MySQL 版本 5.0.85

I've got problem with dropping foreign key index, I always get the same error

 ALTER TABLE `comments` DROP INDEX `id_user`  

which outputs

 1025 - Error on rename of './postuj_cz1/#sql-d834_a0c704' 
 to './postuj_cz1/comments' (errno: 150) 

The id_user on the other table is simple primary key index.

I'm using MySQL version 5.0.85

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

无远思近则忧 2024-08-12 10:23:06

还有其他原因。例如,我有一个涉及两个单独的外键列的唯一索引。在删除唯一索引之前,我必须删除有问题的外键。 (显然您可以稍后添加外键。)

There are other causes too. For example I had a unique index involving two separate foreign key columns. I had to drop the foreign keys in question before I could drop the unique index. (And obviously you can add the foreign keys back afterward.)

遮了一弯 2024-08-12 10:23:06

INNODB :这可能就像在删除索引之前删除关系一样简单。

INNODB : this could be as simple as removing the Relation before dropping the Index.

李白 2024-08-12 10:23:06

根据 此链接,错误与主键字段的定义有关。该错误与外键索引无关。

检查 COMMENTS 表的主键,确保它不具有 UNSIGNED 关键字,而 COMMENTS.id_user 外键具有 UNSIGNED 关键字。该关键字导致了问题 - 字段类型不一致。

要修复此问题,请将 UNSIGNED 关键字添加到 COMMENTS 表的主键定义中。或者从外键定义中删除 UNSIGNED 关键字...

According to this link, the error relates to the definition of the primary key field. The error isn't about the foreign key index.

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.

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...

再可℃爱ぅ一点好了 2024-08-12 10:23:06

该索引用于“用户”表上的外键,因此
首先,尝试以下命令:

SHOW CREATE TABLE my_table

查找与外键上的索引相对应的约束名称,

然后尝试以下命令:

ALTER TABLE my_table DROP FOREIGN KEY FK_myconstraintcode

警告:如果尝试删除具有外键名称的外键,您将得到一个错误到!

The index is for an foreign key on 'user' table, so
In first, try this command:

SHOW CREATE TABLE my_table

Find the name of the constraint corresponding to the index on the foreign key,

and after that, try the command:

ALTER TABLE my_table DROP FOREIGN KEY FK_myconstraintcode

WARNING: If you try to drop the foreign key with the foreign key name, you will have an error to!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文