Created
May 16, 2013 15:43
-
-
Save jibbius/5592685 to your computer and use it in GitHub Desktop.
MySQL - Drop Tables WHERE tablename like();
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 - Drop Tables WHERE tablename like(); | |
*/ | |
SET @tables = NULL; | |
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables FROM information_schema.tables | |
WHERE table_schema = 'db_1' AND | |
( | |
table_name LIKE BINARY 'wp_bp_%' | |
OR table_name LIKE BINARY 'wp_sam_%' | |
OR table_name LIKE BINARY 'wp_rg_%' | |
OR table_name LIKE BINARY 'wp_post%' | |
); | |
SET @tables = CONCAT('DROP TABLE ', @tables); | |
PREPARE stmt1 FROM @tables; | |
EXECUTE stmt1; | |
DEALLOCATE PREPARE stmt1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment