I discussed earlier Difference between drop and truncate.Now let us see the Difference between Delete and truncate S.No | Delete | Truncate |
1. | The Delete command under the Data Manipulation Language | The Truncate command under the Data Definition Languag |
2. | DELETE is a command that allows the programmer to delete a single row from a table in a SQL database. | The TRUNCATE command allows the programmer to delete all rows from a table in a SQL database. |
3. | Allows Filters o certain data. | Does not allows Filters. |
4. | The DELETE command is executed using a row lock, where each row in the table is locked for deletion | The TRUNCATE command locks the table and page but not each row |
5. | Activates a trigger because the operation are logged individually | cannot activate a trigger because the operation does not log individual row deletions |
6. | Deletes specified data where condition exists | Removes all data in the table |
7. | Allows Rollback or undo option | Does not allow rollback or undo option |
8. | Slower in performance as it keeps logs | Faster than Delete as it does not keep logs |
No comments: