Drop all tables in a database

Public

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
bash
  1. mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep -e '^DROP \| FOREIGN_KEY_CHECKS' | mysql -u[USERNAME] -p[PASSWORD] [DATABASE]

Comments

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' ?