Skip to content
Sean Chen edited this page Jul 31, 2014 · 1 revision

Tips for using MariaDB

How to drop a set of tables with same prefix

We will use MediaWiki tables as example. Create a new file named concat-drop.sql with the following SQL:

SELECT CONCAT('DROP TABLE ', GROUP_CONCAT(TABLE_NAME), ';')
AS STATEMENT FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE 'mw_%';

Then, execute it as below:

$ mysql -u user -ppassword dbname < concat-drop.sql