How to drop several MySQL tables
Well, today @work, I had to remove several tables in once (+/- 1500 tables) and as a lazy sysadmin, there is no way I spent my time to delete table by table.
So here, a little MySQL trick:
SELECT CONCAT('DROP TABLE ',GROUP_CONCAT(CONCAT('`',table_schema'`','.','`',table_name,'`')),';')
WHERE table_schema = 'foo'
AND table_name LIKE '%bar%' ;
PREPARE s1 FROM @droptables;
DEALLOCATE PREPARE s1;
And voila. More or less 4 secondes. Luv’ it.