Biomathematicus

Science, Technology, Engineering, Art, Mathematics

The problem: I have a MySQL database schema with 100+ tables and I want to delete all tables using a simple command.

The solution: Most solutions out there tell you to use a cryptic command line argument. You can actually do it with two SQL queries:

First, list all tables in the MySQL schema:

SELECT CONCAT('drop table ',table_name,'; ')
FROM information_schema.tables
WHERE table_schema = 'yourDatabaseName';

This query will result in a list of commands like

drop table table1;
drop table table2;
-- and so on

Second, copy this list, paste it into a query window (in MySQL Workbench) and execute.