Created
December 20, 2017 07:13
-
-
Save egulhan/7974d8803551407286657b7504b1019b to your computer and use it in GitHub Desktop.
Drop all MySQL database tables without foreign key checks
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
### connect mysql with -s and -r parameter to print "DROP TABLE ..." lines without formated | |
mysql -u -s -r | |
### run the following sql query to generate "DROP TABLE ..." queries | |
SELECT concat('DROP TABLE IF EXISTS ', table_name, ';') | |
FROM information_schema.tables | |
WHERE table_schema = '{DBNAME}'; | |
### disable foreign key check | |
SET FOREIGN_KEY_CHECKS = 0; | |
### copy-paste your "DROP TABLE ..." sql queries | |
### enable foreign key check again | |
SET FOREIGN_KEY_CHECKS = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment