Home »
SQL
Using TRUNCATE TABLE in SQL
In this article, we are going to learn about TRUNCATE TABLE to delete complete data from an existing table in SQL.
Submitted by Manu Jemini, on March 06, 2018
There are times when you want to delete the whole records from the table but also to keep the table. Now, we cannot do this by dropping the table itself as we will lose the table itself.
To make this possible to actually keep the table we need truncate the table by a SQL query. This has a very simple syntax because all we need to do is to use the truncate keyword and give it a TableName.
TRUNCATE TABLE table_name;
This is enough to delete every record from the table. There are cases when you really do not have any way other than deleting every record one by one, which could be very hard. Hence, learning this query will help you a lot.
Dummy data:
Syntax:
TRUNCATE TABLE table_name;
Example 1:
TRUNCATE TABLE 'includehelp'.'employee';
Example 2:
TRUNCATE TABLE 'includehelp'.'company';