create table test_table
(id int,c2 varchar2(20),c3 varchar2(20),c4 varchar2(20) );
declare
begin
for i in 1..10000 loop
insert into test_table values(i,lpad(i,20,'x'),lpad(i,20,'y'),lpad(i,20,'z'));
end loop;
commit;
end;
/
delete from test_table ;
commit;
declare
type test_type is table of test_table%rowtype;
v_test test_type :=test_type();
begin
v_test.extend(10000);
for i in 1..10000 loop
v_test(i).id := i;
v_test(i).c2 := lpad(i,20,'x');
v_test(i).c3 := lpad(i,20,'y');
v_test(i).c4 := lpad(i,20,'z');
end loop;
forall j in v_test.first..v_test.last
insert into test_table values v_test(j);
commit;
end;
/
create table test_copy_table
(id int,c2 varchar2(20),c3 varchar2(20),c4 varchar2(20) );
begin
insert into test_copy_table select * from test_table;
commit;
end;
/
delete from test_copy_table;
commit;
declare
type test_type is table of test_copy_table%rowtype;
v_test test_type;
begin
select * bulk collect into v_test from test_table;
forall i in v_test.first .. v_test.last
insert into test_copy_table values v_test(i);
commit;
end;
/
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/50509/viewspace-174262/ ,如需转载,请注明出处,否则将追究法律责任。