Home »
MySQL
MySQL TRUNCATE TABLE Statement
MySQL | TRUNCATE TABLE: Learn about the MySQL TRUNCATE TABLE Statement, with its explanation, syntax, and query examples.
Submitted by Apurva Mathur, on September 20, 2022
TRUNCATE TABLE Statement
Sometimes, when we making some project so most of the time we fill unnecessary data in the table, so to only remove the data of the table without disturbing the definition of the table we use TRUNCATE statement, this statement helps us to delete all the data of a table.
TRUNCATE TABLE Statement Syntax
Truncate TABLE table_name;
TRUNCATE TABLE in MySQL Command-Line Client
Suppose we have a table named "details" and I have the following columns inside this table;
Now if I want to delete the data from this table, I will write the following query,
After hitting this query our table data is deleted successfully.
TRUNCATE TABLE in MySQL Workbench
To truncate a table in MYSQL workbench you have follow some steps;
Step 1: From the schemas section, select the table you want to truncate.
Step 2: After selecting the table, right click on the table and click on truncate table.
Step 3: Once, you'll click on truncate table following options will be visible to you,
Step 4: Click on Truncate.
Your data is deleted successfully.
NOTE: Always take a backup before truncating any table, as then you cannot retrieve the data.