Skip to content

Instantly share code, notes, and snippets.

@EdoardoVignati
Last active March 20, 2019 14:33
Show Gist options
  • Save EdoardoVignati/4694505ffc1fd10692010ac992170c82 to your computer and use it in GitHub Desktop.
Save EdoardoVignati/4694505ffc1fd10692010ac992170c82 to your computer and use it in GitHub Desktop.
DELETE all tables in a database using MySQL
# Just copy the following lines changing [databasename] and execute it.
SELECT CONCAT('DROP TABLE ', GROUP_CONCAT(table_name SEPARATOR ','))
AS delete_stmt INTO @query
FROM information_schema.tables WHERE table_schema = '[databasename]';
PREPARE stmt_drop FROM @query;
EXECUTE stmt_drop;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment