The Largest Online Resource for Oracle Articles, Oracle Tips, Oracle Scripts & Oracle Tools!!


Enter your Email:
 
Navigate at FreeMegaZone Home      Articles      Tools      Jobs      Games      Support      Submit Content      Advertise

Advertise at FreeMegaZone

Give tremendous boost to your business by advertising at FreeMegaZone. Contact webmaster@freemegazone.com

 

Rating: *****                                             Rate this article:    

Author: Steve Keating

Being Oracle database administrator the job of performing bulk deletes must not be new for you. Many times it happens that we have to schedule a job that deletes many records in the database. However the problem we face in such cases is that many rollback segments are generated as a result of this job. Therefore it is the responsibility of database administrator to use some efficient approach for avoiding the generation of rollback segments in bulk delete.

In this article we will discuss some great tips that will help you reduce the generation of rollback segments in bulk deletes. (Article Continues below...)

Using TRUNCATE Statement:

One simple solution to solve this problem is to use TRUNCATE statement instead of DELETE statement. The benefit of using TRUNCATE statement is that all your records in the table will be deleted without generation of any rollback segment. However you can not apply this solution in all scenarios. For example you can not use TRUNCATE command to delete partial records from the table.

Using DELETE Command in Iterations:

Another possible solution to this problem is to run the DELETE commands iteratively so as to minimize the generation of rollback segments. Below code can be used to clean up the rollback segments after every deletion of 1500 table records. Once the rollback segments are cleaned up then they can be reused again and again thus reducing the overhead of generating so many rollback segments as a result of bulk delete.

DECLARE
MYDELCOUNT NUMBER;

     BEGIN

          LOOP

              DELETE
              FROM MYTABLE
              WHERE
             (
                    ROWNUM<1501'
                    AND
                    MYOTHERCONDITION
              );
              
              SELECT COUNT(ROWID)
              FROM MYTABLE
              INTO MYDELCOUNT;
                  
              COMMIT;
              EXIT WHEN MYDELCOUNT = 0;
          END LOOP ;

     END;
Read Again!!

 

 More Database Articles
   Database Security: Step by step guideline
   Improve performance by Optimizing SQL!!
   Amazing Tips to Fix Broken Oracle ASM Instance!!
   Some Facts about Oracle Business Strength
   Great Tips on Reusing Space after deletion of database data!!


 

 
HOME      ABOUT US      SUPPORT      SITE MAP      PRIVACY POLICY      TERMS OF USE      SUBMIT CONTENT      ADVERTISE
Copyright © 2007 - 2010 Oriole Intellect Inc. All rights reserved.

The name Oracle is a trademark of Oracle Corporation. Any other names used on this website may be trademarks of their respective owners