我无法在mysql中删除外键

use*_*484 6 mysql sql

我想在php admin(mysql)中删除一个foriegn键,所以我在下面执行以下代码:

`ALTER TABLE Image_Question DROP INDEX FK_QuestionSession`
Run Code Online (Sandbox Code Playgroud)

问题是我收到此错误:

#1553 - Cannot drop index 'FK_QuestionSession': needed in a foreign key constraint 
Run Code Online (Sandbox Code Playgroud)

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

谢谢

Zef*_*ryn 17

首先删除外键约束然后删除索引.否则你总会得到错误.

alter table Image_Question drop foreign key key_name_here
Run Code Online (Sandbox Code Playgroud)