All those who have shared hosting we have sometimes had the need to delete the contents of a database. How simple it is to completely remove the database and re-create it, but sometimes this is not possible because we don't have permissions to do so.
The following query will allow this us whenever we have access to "information_schema" (which is very likely).
We must first access the database that you want to purge
And then execute the following Query:
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN = 32768;
SET @tables = NULL;
SELECT GROUP_CONCAT(''', table_name, ''') INTO @tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
DEALLOCATE PREPARE stmt;
SET FOREIGN_KEY_CHECKS = 1;
This query generates a subquery of the style "DROP TABLE IF EXISTS t1, t2,…"