Drop all tables in a database


This works even for tables with constraints (foreign key relationships). Alternatively you can just drop the database and recreate, but you may not have the permission to do that.

</> CopyGet raw version
  1. mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep -e '^DROP \| FOREIGN_KEY_CHECKS' | mysql -u[USERNAME] -p[PASSWORD] [DATABASE]


dalin's picture

@todo need to wrap table names in ` to prevent errors on tables that have hyphens

Chi's picture

How about 'drush sql-drop' ?