Delete vs Truncate in SQL SERVER
SQL Server commands Delete vs Truncate
Delete Command:
1.We can delete all or specific rows using WHERE clause in a table
2. Logs are maintained for deleted records
3. Slower than Truncate because of logging
4. Identity column value wouldn’t be reset after deleting all the records
5. We can rollback the deleted records, since logs are maintained in the temp db.
Eg: DELETE "table name"
Truncate Command:
1.We can not use WHERE clause in a table
2.Logs are not maintained for deleted records
3.Faster than Delete because of logging is not done
4.Identity column value will be reset after truncating records
5. We can't roll back records which are truncated
Eg: TRUNCATE TABLE "table name"
Delete Command:
1.We can delete all or specific rows using WHERE clause in a table
2. Logs are maintained for deleted records
3. Slower than Truncate because of logging
4. Identity column value wouldn’t be reset after deleting all the records
5. We can rollback the deleted records, since logs are maintained in the temp db.
Eg: DELETE "table name"
Truncate Command:
1.We can not use WHERE clause in a table
2.Logs are not maintained for deleted records
3.Faster than Delete because of logging is not done
4.Identity column value will be reset after truncating records
5. We can't roll back records which are truncated
Eg: TRUNCATE TABLE "table name"
Comments
Post a Comment