unable to drop the foreign key(无法删除外键)
问题描述
我想在我的表中删除外键,但出现此错误消息
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]
这篇关于无法删除外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法删除外键
基础教程推荐
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 在多列上分布任意行 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
