Sunday, 7 May 2017

SQL Truncate Statement

In this post, I will explain the SQL Truncate Statement.

The Truncate statement is used to remove all records from a table. It performs the same function as a DELETE statement without a WHERE clause.

Few things to Note about Truncate -
1. Truncate operation on a table resets identity column counter
2. If table is referenced by a foreign key, then one cannot perform Truncate operation on table
3. To perform Truncate operation on a table, one should have a ALTER Table permissions
4. Truncate table is a fast way to clear all records from a table
5. Truncate operation cannot be rolled back if it is committed

Example -
TRUNCATE TABLE tbl_Employee

0 comments:

Post a Comment

Please do not enter any spam link in the message box.