无法删除外键 [英] unable to drop the foreign key

查看:37
本文介绍了无法删除外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的表中删除外键,但出现此错误消息

I would like to drop the foreign key in my table but been into this error message

mysql> alter table customers drop foreign key customerid;
ERROR 1025 (HY000): Error on rename of '.productscustomers' to '.products#sql2-7ec-a3' (errno: 152)
mysql>

推荐答案

为避免在尝试删除外键时出现此错误,请使用约束名称而不是外键的列名.

To avoid getting this error while trying to drop a foreign key, use the constraint name rather than the column name of the foreign key.

当我尝试时

mysql> ALTER TABLE mytable DROP PRIMARY KEY;

我得到了错误

ERROR 1025 (HY000): Error on rename of '.database#sql-454_3' to '.databasemytable' (errno: 150).

我解决了这个问题:

mysql> ALTER TABLE mytable DROP PRIMARY KEY, ADD PRIMARY KEY (column1,column2,column3);

一些对你有帮助的链接.

Some links that will help you.

链接1

链接 2 [查找已发布作者:Alex Blume 于 2008 年 11 月 7 日下午 5:09 &Hector Delgadillo 于 2011 年 1 月 21 日凌晨 4:57 发布]

link 2 [look for Posted by Alex Blume on November 7 2008 5:09pm & Posted by Hector Delgadillo on January 21 2011 4:57am]

这篇关于无法删除外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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