title: Fast Update database with more than 10 million records
body: <p>I am fairly new to SQL and was wondering if someone can help me.</p>
  
  <p>I got a database that has around 10 million rows.</p>
  
  <p>I need to make a script that finds the records that have some NULL fields, and then updates it to a certain value.</p>
  
  <p>The problem I have from doing a simple update statement, is that it will blow the rollback space.</p>
  
  <p>I was reading around that I need to use BULK COLLECT AND FETCH.</p>
  
  <p>My idea was to fetch 10,000 records at a time, update, commit, and continue fetching.</p>
  
  <p>I tried looking for examples on Google but I have not found anything yet.</p>
  
  <p>Any help?</p>
  
  <p>Thanks!!</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>DECLARE
      CURSOR rec_cur IS
      SELECT DATE_ORIGIN 
      FROM MAIN_TBL WHERE DATE_ORIGIN IS NULL;
  
      TYPE date_tab_t IS TABLE OF DATE;
  
      date_tab date_tab_t;
  
  BEGIN
      OPEN rec_cur;
      LOOP
          FETCH rec_cur BULK COLLECT INTO date_tab LIMIT 1000;
          EXIT WHEN date_tab.COUNT() = 0;
  
          FORALL i IN 1 .. date_tab.COUNT
              UPDATE MAIN_TBL SET DATE_ORIGIN  = '23-JAN-2012' 
              WHERE DATE_ORIGIN IS NULL;
  
      END LOOP;
      CLOSE rec_cur;
  END;
  </code></pre>