Q 16. What is the difference between DELETE and TRUNCATE commands?
Ans :-
The DELETE statement removes rows one at a time and records an entry in the transaction log for each deleted row. | TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction log. |
DELETE command is slower than the identityTRUNCATE command. | While the TRUNCATE command is faster than the DELETE command. |
To use Delete you need DELETE permission on the table. | To use Truncate on a table we need at least ALTER permission on the table. |
The identity of the column retains the identity after using DELETE Statement on the table. | The identity of the column is reset to its seed value if the table contains an identity column. |
The delete can be used with indexed views. | Truncate cannot be used with indexed views. |
No comments:
Post a Comment