Reputation: 87
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.
Upvotes: 2
Views: 21162
Reputation: 1112
Upvotes: 2
Reputation: 24046
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>;
Upvotes: 6
Reputation: 1069
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
Upvotes: 1