mysql delete foreign key

Check what's the CONSTRAINT name and the FOREIGN KEY name:

SHOW CREATE TABLE table_name;

Remove both the CONSTRAINT name and the FOREIGN KEY name:

ALTER TABLE table_name
  DROP FOREIGN KEY the_name_after_CONSTRAINT,
  DROP KEY the_name_after_FOREIGN_KEY;

Or simply run this if you know the foreign key name:

alter table footable drop foreign key fooconstraint

原文:https://stackoverflow.com/questions/838354/mysql-removing-some-foreign-keys