Since there exists neither DROP TABLE * nor DROP TABLE WHERE name LIKE ‘something’, here are two ways to achieve the same:
For version 5.0+:
mysql -N -e "SELECT CONCAT('DROP TABLE ', GROUP_CONCAT(table_name), ';') FROM information_schema.tables WHERE table_schema = 'dbName'" | mysql dbName
For any version on a platform with grep available:
mysqldump --add-drop-table -d dbName | grep -e "DROP TABLE" | mysql dbName
For any version on Windows:
mysqldump --add-drop-table -d dbName | findstr /B "DROP TABLE" | mysql dbName
You can alter the WHERE clause of the first or the grep of the second to support whatever specifics you like, such as all the tables that have a common prefix.

Leave a Reply