无法放弃外键 [英] unable to drop the foreign key

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

问题描述

我想把外键放在我的表中,但是进入了这个错误信息。

  mysql>改变表客户放弃外键customerid; 
ERROR 1025(HY000):将'.\products\customers'重命名为'.\products\#sql2-7ec-a3'(errno:152)
mysql>


解决方案

键,使用约束名称而不是外键的列名称。

当我试过时

 的MySQL> ALTER TABLE mytable DROP PRIMARY KEY; 

我得到错误信息

 错误1025(HY000):将'.\database\#sql-454_3'重命名为'.\database\mytable'(errno:150)时出错。 

我解决了这个问题:

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

有些链接可以帮助您。

链接1



链接2 [寻找Alex Blume发表于2008年11月7日5:09 pm&发表于2011年1月21日上午4:57] Hector Delgadillo


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 '.\products\customers' 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.

When I tried

mysql> ALTER TABLE mytable DROP PRIMARY KEY;

I got error as

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

I solved it using:

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

Some links that will help you.

link 1

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天全站免登陆