2012-09-29 25 views
6

我想放弃在PHP管理(MySQL的)一个foriegn关键,所以我下面执行该代码:我无法放弃MySQL中的外键

`ALTER TABLE Image_Question DROP INDEX FK_QuestionSession` 

问题是,虽然,我收到此错误:

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

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

谢谢

+0

可能重复http://stackoverflow.com/questions/8482346/mysql-cannot-drop-index-needed-in-a-foreign-键约束) – Kariem

回答

16

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

alter table Image_Question drop foreign key key_name_here 
的[MySQL不能下降外键约束需要指数(
+1

谢谢我会接受答案,当它让我在几分钟 – user1701484