Bouw het statement dynamisch op uit de data dictionary en voer het daarna uit als een prepared statement:
SET FOREIGN_KEY_CHECKS = 0; SET @tables = NULL; SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name, '`') INTO @tables FROM information_schema.tables WHERE table_schema = 'database_name'; -- specify DB name here. SET @tables = CONCAT('DROP TABLE ', @tables); PREPARE stmt FROM @tables; EXECUTE stmt; DEALLOCATE PREPARE stmt; SET FOREIGN_KEY_CHECKS = 1; Het uitschakelen van foreign-key-controles is belangrijk, omdat tabellen in willekeurige volgorde verwijderen anders op constraints mislukt. Heeft je schema heel veel tabellen, verhoog dan eerst group_concat_max_len, anders wordt de gegenereerde lijst afgekapt — en dit statement is uiteraard onomkeerbaar, dus maak een back-up voordat je het uitvoert.