批量提交 網上整理

2021-08-27 13:29:07 字數 2072 閱讀 7687

update批量提交

create table t2 as select object_name from dba_objects;

declare

type ridarray is table of rowid;

type vcarray is table of t2.object_name%type;

l_rids ridarray;

l_names vcarray;

cursor c is select rowid,object_name from t2;

begin

open c;

loop

fetch c bulk collect into l_rids,l_names limit 100;

forall i in 1..l_rids.count

update t2

set object_name=lower(l_names(i))

where rowid=l_rids(i);

commit;

exit when c%notfound;

end loop;

close c;

end;

/

--分批delete

drop table t3;

create table t3 as select * from dba_objects;

declare

cursor mycursor is select rowid from t3 order by rowid; --------按rowid排序的cursor,刪除條件是***=***x,根據實際情

type rowid_table_type is table of rowid index by pls_integer;

v_rowid rowid_table_type;

begin

open mycursor;

loop

fetch mycursor bulk collect into v_rowid limit 5000; --------每次處理5000行,也就是每5000行一提交

exit when v_rowid.count=0;

forall i in v_rowid.first..v_rowid.last

delete from t3 where rowid=v_rowid(i);

commit;

end loop;

close mycursor;

end;

/ --分批insert

drop table t4;

drop table t5;

create table t4 as select * from dba_objects;

create table t5 as select * from t4 where 1=0;

declare

cursor mycursor is select rowid from t4 order by rowid; --------按rowid排序的cursor,刪除條件是***=***x,根據實際情

type rowid_table_type is table of rowid index by pls_integer;

v_rowid rowid_table_type;

begin

open mycursor;

loop

fetch mycursor bulk collect into v_rowid limit 5000; --------每次處理5000行,也就是每5000行一提交

exit when v_rowid.count=0;

forall i in v_rowid.first..v_rowid.last

insert into t5 select * from t4 where rowid=v_rowid(i);

commit;

end loop;

close mycursor;

end;

oracle批量提交

create or replace procedure p cust bossorder sync is 存放t iiss boss order back是否存在 v tablecount number 2 0 定義變數 type v bossorder row is table of t cust...

spring ibatis 批量提交資料

在系統中,提取資料迴圈計算後,每次需要有大概3000條左右的資料需要提交到資料庫。以前在迴圈中單條插入,開始只有200條左右的資料,看不出效能上的問題,現在資料量增長了很多,所以需要對提交功能做一下優化。spring整合了ibatis的批量提交的功能,我們只要呼叫api就可以了 首先在你的dao中需...

批量提交(plsql,游標)

需求 批量提交修改資料,其中需要修改的資料有 23萬多條。declare cursor l c1 is select u.id from 系統名 可不寫 表名 u where 條件 定義游標 type t1 is table of pls integer l t1 t1 begin open l c...