无法在mysql中删除外键

7

我正在尝试在php admin(mysql)中删除一个外键,因此我执行以下代码:

`ALTER TABLE Image_Question DROP INDEX FK_QuestionSession`

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

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

QuestionId 的外键从 Image_Question 表连接到 Question 表中的 QuestionId。谢谢。

可能是重复的问题:MySQL无法删除外键约束中所需的索引 - Kariem
1个回答

19

首先移除外键约束,然后再删除索引。否则你会一直收到错误信息。

alter table Image_Question drop foreign key key_name_here

1
谢谢,我会在几分钟内接受答案。 - user1701484
谢谢,对我有用。 - Amit Kumar Khare

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接