You have a database with multiple tables, which is the most effective way to empty it?

1. Using the DROP command

If you have the drop and create privileges on the database and don’t want to keep anything in it, the most effective way to to drop the database and create a new one with the same name.

To drop database:

DROP DATABASE db_name;

Then recreate it:

CREATE DATABASE db_name;

2. Using mysqldump

You can empty the database using this mysqldump command:

mysqldump -u[user] -p[ssht...] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[user] -p[sshht...] [DATABASE]

3. Using TablePlus GUI

With TablePlus, you can also empty the database by selecting all of its objects on the left sidebar and delete.

TablePlus empty db


Need a good GUI tool for databases? TablePlus provides a native client that allows you to access and manage Oracle, MySQL, SQL Server, PostgreSQL, and many other databases simultaneously using an intuitive and powerful graphical interface.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS

TablePlus in Dark mode