Created
May 25, 2021 07:47
-
-
Save jyotendra/27191913df9b4cfdb9b4e6d5fb664539 to your computer and use it in GitHub Desktop.
This sql script helps to drop entire scema from a database
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
SET FOREIGN_KEY_CHECKS = 0; | |
SET SESSION group_concat_max_len = 1000000; | |
SET @TABLES = NULL; | |
SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name,'`') INTO @TABLES FROM information_schema.tables | |
WHERE table_schema = 'databaseName'; | |
SET @TABLES = CONCAT('DROP TABLE IF EXISTS ', @TABLES); | |
PREPARE stmt FROM @TABLES; | |
EXECUTE stmt; | |
DEALLOCATE PREPARE stmt; | |
SET SESSION group_concat_max_len = 1024; | |
SET FOREIGN_KEY_CHECKS = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credits to original post.
Replace the "databaseName" with name of your DB.