Friday, October 3, 2008

What is difference between TRUNCATE & DELETE ? in SQL

What is difference between TRUNCATE & DELETE ?

TRUNCATE commits after deleting entire table i.e., can not be rolled back. Database triggers do not fire on TRUNCATEDELETE allows the filtered deletion. Deleted records can be rolled back or committed. Database triggers fire on DELETE.

oracle- What are the usage of SAVEPOINTS ?

What are the usage of SAVEPOINTS ?

SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a transaction. Maximum of five save points are allowed.

Eg -
update emp set sal=sal+100 where empid <>
savepoint a;
update emp set sal=sal+50 where empid <>
savepoint b;
update emp set sal=sal+150 where empid <>
savepoint c;
update emp set commission=0 where designation = manager;

rollback to savepoint b;
-- above statement rollbacks all statements issued after the savepoint b;

For more detailed information, please refer oracle offial site which gives much broader view of the scenario and usage.
SAVEPOINT

My Blog List