What is the difference between TRUNCATE and DELETE in Oracle?

1 Answers
Answered by suresh

Difference between TRUNCATE and DELETE in Oracle

Difference between TRUNCATE and DELETE in Oracle

TRUNCATE and DELETE are both SQL commands used to remove data from a table in Oracle, but they have some key differences:

TRUNCATE:

TRUNCATE is a DDL (Data Definition Language) command that removes all rows from a table, but does not log individual row deletions. It is a faster operation compared to DELETE since it does not generate undo records or fire triggers. However, TRUNCATE cannot be rolled back and it also resets any sequence values associated with the table.

DELETE:

DELETE is a DML (Data Manipulation Language) command that removes specific rows based on a condition from a table. It logs each row deletion, generates undo records for each row, and fires triggers if they are set up. DELETE can be rolled back using a ROLLBACK command and does not reset sequence values.

In summary, TRUNCATE is faster and cannot be rolled back, while DELETE is slower but offers more flexibility and allows for individual row deletions to be rolled back.

Answer for Question: What is the difference between TRUNCATE and DELETE in Oracle?