Difference between TRUNCATE, DELETE and DROP commands

Delete — The DELETE command is used to remove some rows from a table.
using where clause.
Note that this operation will cause all DELETE triggers on the table to fire.

TRUNCATE removes all rows from a table.
The operation cannot be rolled back ,
no triggers will be fired.
As such, TRUNCATE is faster and doesn’t use as much undo space as a DELETE.
Reason –>
TRUNCATE is much faster than DELETE.

Reason:When you type DELETE.all the data get copied into the Rollback Table space first.
then delete operation get performed.performed. That’s why when you type ROLLBACK after deleting a table ,
you can get back the data(The system get it for you from the Rollback Table space).
All this process take time.But when you type TRUNCATE,it removes data directly without copying it into the Rollback Table space.
That’s why TRUNCATE is faster.Once you Truncate you can’t get back the data.
The DROP command removes a table from the database
All the tables’ rows, indexes and privileges will also be removed.
No DML triggers will be fired.
The operation cannot be rolled back.

DROP and TRUNCATE are DDL commands
whereas DELETE is a DML command.
Therefore DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.
DML can be rolled out whereas DDL can’t be rolled out.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s