Created
May 31, 2013 04:38
-
-
Save hummus/5682969 to your computer and use it in GitHub Desktop.
mysql: quick drop all foreign key constraints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql -u $USER -p$PASS -e 'select * from information_schema.TABLE_CONSTRAINTS where CONSTRAINT_TYPE="FOREIGN KEY"' -B | awk '{if (NR!=1) print("ALTER TABLE "$2"."$5" DROP FOREIGN KEY "$3";")}' | mysql -u $USER -p$PASS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment