Forall insert

From Tom's notes
Jump to navigation Jump to search

Create table containing 100M records:

create table testtable(id number);

declare
  type t_table is table of testtable%rowtype index by binary_integer;
  t_arr t_table;
  
  million number;
begin
  for m in 0 .. 99 loop
    million := m * 1000000;
    for i in 0 .. 999999 loop
      t_arr(i).id := million + i;
    end loop;
    
    forall i in t_arr.first .. t_arr.last
      insert into testtable values t_arr(i);

    commit;
  end loop;
end;
/