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


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;

truncate table statement step 1

Now if I want to delete the data from this table, I will write the following query,

truncate table statement step 2

After hitting this query our table data is deleted successfully.

truncate table statement step 3


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.

truncate table statement step 4

Step 2: After selecting the table, right click on the table and click on truncate table.

truncate table statement step 5

Step 3: Once, you'll click on truncate table following options will be visible to you,

truncate table statement step 6

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.


Comments and Discussions!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.