Skip to content

Instantly share code, notes, and snippets.

@amcclosky
Created May 26, 2011 21:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amcclosky/994139 to your computer and use it in GitHub Desktop.
Save amcclosky/994139 to your computer and use it in GitHub Desktop.
This will return a list of alter table statements which drop all foreign keys from the given database in MySQL. (via http://goo.gl/9ZD9N)
SELECT concat('alter table ',table_schema,'.',table_name,' DROP FOREIGN KEY ',constraint_name,';') from information_schema.table_constraints WHERE constraint_type='FOREIGN KEY' AND table_schema='<database_name>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment