1.

Differentiate between Delete and Truncate SQL commands.

Answer»

The following table lists the differences between Delete and Truncate SQL commands:

DeleteTruncate 
The DELETE command is used to remove specific rows from a table (one or more).This command is used to delete all of the rows in a table.
It is a Data Manipulation Language (DML) command.It is a Data Definition Language (DDL) command.
In order to filter the RECORDS, the DELETE command may include a WHERE clause.The TRUNCATE command may not use a WHERE clause.
The DELETE statement deletes rows one by one and records each deleted ROW in the transaction log.TRUNCATE TABLE deletes data by relocating the data pages that were used to HOLD the table data, and only the page deallocations are recorded in the transaction log.
A tuple is locked before being deleted with the DELETE statement.Before removing the table data, the data page is locked in this command.
DELETE permission on the table is required to use Delete. To use Truncate on a table, the table must have at least ALTER permission.
The DELETE command is more time consuming than the TRUNCATE command.The TRUNCATE command, on the other hand, is faster than the DELETE command.
With indexed views, the delete command can be used.Truncate isn't compatible with indexed views.
After PERFORMING the DELETE Statement on the table, the identity of the column is preserved.If the table contains an identity column, the column's identity is reset to its seed value.


Discussion

No Comment Found