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;

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

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.

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!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.