⚡ 180+ new openings posted today

SQL TRUNCATE Statement

What is the TRUNCATE Statement in SQL ?

Answer : The SQL TRUNCATE statement is used to remove all records from a table. It performs the same function as a DELETE statement without a WHERE Clause. if you want to truncate a table, the TRUNCATE TABLE statement cannot be rolled back.

Syntax

TRUNCATE TABLE table_name;

Suppose we have an Employees table:

Employee_IDEmployee_NameSalary
101Anjali50000
102Priya45000
103Amit55000

To remove all records:

TRUNCATE TABLE Employees;

After TRUNCATE

Employee_IDEmployee_NameSalary

The Employees table still exists, but all its records have been removed.

DELETE vs TRUNCATE

DELETETRUNCATE
Can delete specific rows using WHERERemoves all rows
WHERE can be usedWHERE cannot be used
Generally logs row-level deletionsGenerally performs a more bulk-oriented removal
Table structure remainsTable structure remains

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top