我无法在 mysql 中删除外键

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12656967/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:02:28  来源:igfitidea点击:

I am unable to drop a foreign key in mysql

mysqlsql

提问by user1701484

I am trying to drop a foriegn key in php admin (mysql) so I am performing this code below:

我试图在 php admin (mysql) 中删除一个外键,所以我正在执行下面的代码:

`ALTER TABLE Image_Question DROP INDEX FK_QuestionSession`

Problem is though that I am receiving this error:

问题是我收到了这个错误:

#1553 - Cannot drop index 'FK_QuestionSession': needed in a foreign key constraint 

The foreign key for QuestionId is linked from the Image_Question Table to the QuestionId in the Question Table.

QuestionId 的外键从 Image_Question 表链接到问题表中的 QuestionId。

Thanks

谢谢

回答by Zefiryn

Remove foreign key constrain first and then drop index. Otherwise you will always get error.

首先删除外键约束,然后删除索引。否则你总是会出错。

alter table Image_Question drop foreign key key_name_here