Forall insert

From Tom's notes
Revision as of 12:10, 4 April 2016 by 193.121.160.69 (talk) (Created page with "Create table containing 100M records: <source lang="plsql"> create table testtable(id number); declare type t_table is table of testtable%rowtype index by binary_integer;...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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;
/