Created
December 27, 2016 10:00
-
-
Save mmuruev/4597f7c23ef18ef87794211650b88b56 to your computer and use it in GitHub Desktop.
Script for remove in one command all tables in databases, by given template
This file contains hidden or 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 GROUP_CONCAT_MAX_LEN=10000; | |
SET @del = ( | |
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(CONCAT('`' , TABLE_SCHEMA , '`.`',table_name,'`')) , ';' ) | |
AS statement FROM information_schema.tables | |
WHERE | |
TABLE_SCHEMA LIKE 'MY_DB_PREFIX_%' /* Criteria for selection */ | |
OR TABLES.TABLE_NAME LIKE 'MY_TABLE_PREFIX_%'; | |
); | |
PREPARE stmt FROM @del; | |
EXECUTE stmt; | |
DEALLOCATE PREPARE stmt; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment