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:

TRUNCATE TABLE in SQL

Syntax:

TRUNCATE TABLE  table_name;

Example 1:

TRUNCATE TABLE 'includehelp'.'employee';
TRUNCATE TABLE in SQL Output 1

Example 2:

TRUNCATE TABLE 'includehelp'.'company';
TRUNCATE TABLE in SQL Output 2






Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.



Comments and Discussions





© https://www.includehelp.com (2015-2018), Some rights reserved.




close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.