Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am unable to drop a foreign key in mysql

Tags:

sql

mysql

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

`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.

Thanks

like image 566
user1701484 Avatar asked Sep 29 '12 22:09

user1701484


1 Answers

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
like image 179
Zefiryn Avatar answered Sep 22 '22 01:09

Zefiryn