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]
这篇关于无法删除外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法删除外键
基础教程推荐
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
