Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting foreign key tables on phpmyadmin? cannot drop index: needed in foreign key constraint

Tags:

I've been trying to find a way to delete some foreign keys generated by mistake, but each time I DROP the table associated with the foreign key to try and erase it, it says "cannot drop index: needed in foreign key constraint".

like image 223
Roe Avatar asked Sep 02 '14 14:09

Roe


People also ask

Can't drop needed in a foreign key constraint?

If you are getting an error Cannot drop index 'fk_role_id': needed in a foreign key constraint, it means you are trying to drop the index without dropping the foreign key. To drop the index you have to drop the foreign key first. After that, you can drop the index.

How do I delete a foreign key in phpmyadmin?

In "Structure" tab, click on "see relational view" below the fields. Here you can remove the foreign keys by selecting an empty value in the dropdown.

What happens if a foreign key is deleted?

When a referenced foreign key is deleted or updated, respectively, the columns of all rows referencing that key will be set to NULL . The column must allow NULL or this update will fail.

How do I remove a foreign key from a constraint?

To delete a foreign key constraint In Object Explorer, expand the table with the constraint and then expand Keys. Right-click the constraint and then click Delete.


1 Answers

In "Structure" tab, click on "see relational view" below the fields. Here you can remove the foreign keys by selecting an empty value in the dropdown.

like image 126
johanvs Avatar answered Oct 10 '22 02:10

johanvs