how to drop foreign key relation in the mysql table
17,301
Solution 1
probably, you should get the foreign keys using
SHOW CREATE TABLE <your_table>
then delete the foriegn keys one by one
ALTER TABLE <table_name> DROP FOREIGN KEY <key_name>;
Solution 2
Read this will help you http://bugs.mysql.com/bug.php?id=14347
http://www.w3schools.com/sql/sql_foreignkey.asp
The foreign key constraint has to be dropped by constraint name and not the index name. The syntax is:
alter table test_table drop foreign key test_tableconstraint
Solution 3
- Go to structure view of the table
- You will see 2 options at the top
a. Table structure
b. Relation view.
- Now click on Relation view , here you can drop your foreign key constraint.
Author by
Stefan Edwards
Updated on June 04, 2022Comments
-
Stefan Edwards almost 2 years
I have one table X. I need to drop all the foreign keys in the table. I don't know how to drop. Can any one please say the query.
-
Stefan Edwards over 11 yearsOkay.But if i list the foreign keys after the deletion means it'll display again deleted foreign key.