There are a couple of ways we can delete all the data from MySQL tables. Below are the ways which we will discuss.
Delete all the data from MySQL table using Delete Statement
We can delete all the data from the MySQL table by using the delete statement. Below is the syntax of deleting all the data in MySQL.
DELETE * FROM table_name;
Delete * from table_name will delete all the data from MySQL table. table_name is the name of the table from which you want to delete the data.
Delete * from employee;
Delete all the data from MySQL table using Truncate Statement
Another way to delete all the data in MySQL is by using a truncate statement.
Syntax of MySQL truncate statement
Truncate table table_name;
Truncate statement will delete all the data from MySQL table.
Truncate table employee;
It will delete all the data from the employee table.
Drop the table to delete all the data from MySQL
You can drop the table to delete all the data. Drop the table will delete the table from MySQL database, so make sure to use a drop statement.
Syntax of MySQL drop statement
Drop table table_name;