MySQL删除外键问题小结
网络编程 2021-07-05 14:36www.168986.cn编程入门
mysql删除外键抱错Error on rename of ./ruler/test2child to ./ruler/#sql2-298-92 (errno: 152),怎么回事,有好的方法可以解决吗?狼蚁网站SEO优化看下狼蚁SEO长沙网络推广给大家带来的解决思路
MySQL:MySQL不能删除外键,抱错Error on rename of ./ruler/test2child to ./ruler/#sql2-298-92 (errno: 152)
曾经这是MySQL的一个bug,但是现在只是MySQL的一个不友好的地方。
例子如下:
mysql> ALTER TABLE ruler.test2child DROP FOREIGN KEY test; ERROR 1025 : Error on rename of ''./ruler/test2child'' to ''./ruler/#sql2-298-8f'' (errno: 152)
这里并不是不能删除外键,而是使用了错误的外键名称,但是MySQL报的错实在离谱。
正确的错误信息要如下查询才能知道:
mysql> show innodb status; ------------------------ LATEST FOREIGN KEY ERROR ------------------------ 071222 20:48:26 Error in dropping of a foreign key constraint of table "ruler"."test2child", in SQL mand ALTER TABLE ruler.test2child DROP FOREIGN KEY test Cannot find a constraint with the given id "test".
另外外键的其他操作也有类似情况:
比如外键 新建报错:
Can''t create table ''ruler.#sql-298_92'' (errno: 150) show innodb status; ------------------------ LATEST FOREIGN KEY ERROR ------------------------ 071222 20:18:57 Error in foreign key constraint of table ruler/#sql-298_8d: FOREIGN KEY (test2code) REFERENCES ruler.test2 (test) on delete set null: You have defined a SET NULL condition though some of the columns are defined as NOT NULL.
测试数据库版本为:
5.2.0-falcon-alpha-munity-nt
删除外键的做法:
//先删除外键名,再删外键字段(mysql官方提供)
例:
alter table task drop foreign key FK_Reference_7; alter table task drop column `assigned`;
以上所述是长沙网络推广给大家介绍的MySQL删除外键问题小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,长沙网络推广会及时回复大家的。在此也非常感谢大家对狼蚁SEO网站的支持!
上一篇:MySQL binlog中的事件类型详解
下一篇:MySQL外键使用及说明详解
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程