Skip to content

Instantly share code, notes, and snippets.

@ragingprodigy
Created September 8, 2017 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ragingprodigy/9891e8484ae7ea0267a041eb048fec02 to your computer and use it in GitHub Desktop.
Save ragingprodigy/9891e8484ae7ea0267a041eb048fec02 to your computer and use it in GitHub Desktop.
Generate Queries to Delete all Foreign Keys from all tables in the current MySQL Database
SELECT CONCAT("alter table ", TABLE_NAME," drop foreign key ", CONSTRAINT_NAME,"; ") AS runMe
FROM information_schema.key_column_usage
WHERE TABLE_SCHEMA=DATABASE() AND CONSTRAINT_NAME LIKE '%ibfk%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment