ads

Tuesday, April 12, 2016

What is difference between delete and truncate command in oracle.

What is the difference between delete and truncate command in oracle?


Delete is a DML (data manipulation language) so it can be rollback.

Truncate is a DDL (Data Definition language) so once it executed it can’t be rollback.

Delete command remove records row by row at a time from table and record entry in the transaction logs  so the speed of execution is slow.

Truncate remove all records in once so it is faster than delete. 
 
Using delete common you can remove some are all records from the table, we can use WHERE clause with delete. 

Take a look on delete syntax.

Delete syntax
DELETE FROM table_name
[WHERE conditions];

 

Using Truncate you can remove all records in once. We can’t you WHERE clause with truncate command.
Take a look on Truncate syntax.


Truncate syntax
TRUNCATE FROM table_name.


All delete Triggers fire on delete command But Triggers will not fire on truncate Command.
 
Truncate reset the high water mark on table but delete can’t.
 
Truncate release the space from the table but delete can’t.


Watch PLSQL Interview Q&A videos
 https://www.youtube.com/user/rameshwargupta1/videos

No comments:

Post a Comment