Truncate Table command allows us to delete all the data in the table without deleting the table itself. This command does not delete the entire table, but it only deletes the records inside the table.
In this tutorial we will learn to truncate a table in SQL.
Step 1- Viewing Table Data
First of all let us view the records from any table, let it be dummy in our case.
For that write:
Select * from dummy
and execute it by pressing F5.
Step 2- Executing Command
Now write the Truncate Table command along with the required table name.
The query would be:
Truncate table dummy
and execute it .
Step 3- Data Removed
Now view the records of dummy table again, you will observe that the table would be empty with no records present.
That is what the Truncate Table query does.
And that is how we can truncate a table in SQL.