Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to delete 60 million rows

849776Apr 12 2011 — edited Apr 12 2011
Hi all,

I have table tb1 with 60 million and i have another table tb2 with 30 million

I want to delete tab2 with respect to table one

For this i wrote a procedure to dellete this . but when iam trying to execute after 4 min the procedure is not running due to large data:

 PROCEDURE temp (id IN NUMBER)
AS
   CURSOR c
   IS
      SELECT order
        FROM tab1
       WHERE (status = 'A'
              AND billdt < ADD_MONTHS (SYSTIMESTAMP, -12))
             OR (status IN ('B','C')
                 AND orderdt < ADD_MONTHS (SYSTIMESTAMP, -12));

   TYPE ordernum IS TABLE OF tab1.order%TYPE;

   order1   ordernum;
BEGIN

   OPEN c;

   LOOP
      FETCH c
      BULK COLLECT INTO order1
      LIMIT 1000;

      FORALL i IN 1 .. order1.COUNT
         DELETE FROM tb2
               WHERE id = order1 (i);

      EXIT WHEN c%NOTFOUND;
   END LOOP;
   COMMIT;
    EXCEPTION
      WHEN OTHERS
      THEN
         ROLLBACK;
       END ;
       
can any one help me!!!!!!!!

Thanks in advance
This post has been answered by Centinul on Apr 12 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 10 2011
Added on Apr 12 2011
5 comments
97 views