Sr No. | Delete Command | Truncate Command |
1. | It is a DML (Data Manipulation Language) command. | It is a DDL (Data Definition Language) command. |
2. | The DELETE statement is used when we want to remove some or all of the records from the table. | The truncate command removes the complete data from an existing table but not the table itself. It preserves the table structure or schema. |
3. | This command does not reset the table identity because it only deletes the data. | It always resets the table identity. |
4. | It maintains transaction logs for each deleted record. | It does not maintain transaction logs for each deleted data page. |
5. | Its speed is slow because it maintains the log. | Its execution is fast because it deletes entire data at a time without maintaining transaction logs. |
6. | This command can also activate the trigger applied on the table and causes them to fire. | This command does not activate the triggers applied on the table to fire. |
7. | It allows us to restore the deleted data by using the COMMIT or ROLLBACK statement. | We cannot restore the deleted data after executing this command. |
8. | It can be used with indexed views. | It cannot be used with indexed views |
9. | It will lock the row before deletion. | It will lock the data page before deletion. |
10. | This command eliminates records one by one. | This command deletes the entire data page containing the records. |
11. | We need to have DELETE permission to use this command. | We need to have ALTER permission to use this command. |