You are on page 1of 3

DELETE TRUNCATE DROP

delete is logged truncate doesn't log row


level details
doesn't log
should not use DELETE to remove large
data set - slower
TRUNCATE command is
much faster than DELETE
faster
DML DDL DDL
DELETE retains value of identity column. Reset any Identity column
DELETE activates trigger doesn't activate trigger doesn't activate trigger
with DELETE you can define condition in
WHERE clause
Cant define any filter
based upon WHERE clause

DELETE is not auto commit automatically get
committed

Removes all rows from a
table, but the table
structures and its columns,
constraints, indexes
Removes a table from the
database. Table structures,
indexes, privileges,
constraints will also be
removed.
When DELETE operation is performed, all
the data get copied into Rollback Table
space first, and then delete operation get
performed. Hence we can get back the data
by ROLLBACK command.
Cannot be rolled back Cannot be rolled back




DELETE

TRUNCATE DROP
Purpose Deletes some or all
rows of a table
Deletes all rows of a
table
Removes all rows and
also the table
definition, including
indexes, triggers,
grants, storage
parameters
Command Type DML DDL DDL
Space Usage and
Release
Uses UNDO space.
Released blocks that
go to the freelist for
the table, to be used
for subsequent
inserts/updates. Does
not deallocate space.
Does not use UNDO
space.
Deallocates all space
used by the table
except MINEXTENTS.
Does not use UNDO
space.
Unless the PURGE
clause is specified,
does not result in space
being released.
Commit required? Yes No No
Undo possible? Uncommitted deletes
can be rolled back
Cannot be rolled back
once truncated,
gone forever
A dropped table can be
reinstated from the
recycle bin
Selective deletion
possible?
Yes. Filter criteria be
specified via WHERE
clause
No filter criteria
allowed, removes all
rows
No filter criteria
allowed, removes all
rows
Triggers fired? Yes, DELETE triggers
fired
No triggers fired No triggers fired
What if foreign keys
(FKs) based on the
table exist?
Can delete data even
if FKs are enabled,
provided the data
violates no FK
constraint
Cannot delete data if
FKs are enabled; FKs
need to be
disabled/dropped.
Exception: Truncate is
possible if the FK is
self-referential.
Can drop the table with
the CASCADE
CONSTRAINTS option.
This will also remove
the associated FKs
Efficiency DELETE can be slow
especially if the table
has many triggers,
indexes,and other
dependencies
TRUNCATE is most
efficient for deleting
all rows, even more
than dropping and
recreating the table
using DROP
DROP may not be as
efficient as TRUNCATE,
as dropping and re-
creating the table
requires you to re-
grant object privileges,
re-create indexes,
constraints, etc.
Privileges required to
issue the command
DELETE privilege.
DELETE ANY TABLE
allows you to delete
rows from anytable of
any schema.
DROP ANY TABLE
system privilege.


DROP ANY TABLE
system privilege.
Grants DELETE privilege on a
specific table can be
granted to another
user or role.
TRUNCATE privilege
on a specific table
cannot be granted to
another user or role.
DROP ANY privilege on
a specific table cannot
be granted to another
user or role.
Can work outside the
users schema?
Yes, as long as the
user has the DELETE
privilege on the
object.
No. A table can be
truncated in ones
own schema only.
No. A table can be
dropped in ones own
schema only.
Can work on a table
that is part of a
cluster?
Yes No. You will have to
truncate the whole
cluster, or use either
DELETE or DROP.
Yes

You might also like