oracle 分批update更新

2014-05-09 16:46:00
1147533288
原创
3109
摘要:oracle 分批update更新
问题描述:单表,130万数据,更新一个字段。

解决办法:

匿名块执行,先rowid排序,分批每5000更新并提交一次,效果还好。

<!--more-->
declare
maxrows number default 5000;
row_id_table dbms_sql.Urowid_Table;
v_id_table dbms_sql.Varchar2_Table;
cursor acnt_first_cur is
select t.domain_code,t.rowid from
cert_org_index t order by t.rowid;
begin
open acnt_first_cur;
loop
exit when acnt_first_cur%notfound;
fetch acnt_first_cur bulk collect
into v_id_table, row_id_table limit maxrows;
forall i in 1 .. row_id_table.count
update cert_org_index
set domain_code = '320115000001'
where rowid = row_id_table(i);
commit;
end loop;
end;

&nbsp;

&nbsp;

&nbsp;

文章参考:http://hi.baidu.com/songyunkui/item/04aba589f7ffa705100ef3c1
文章分类
联系我
联系人: meepo
电话: *****
Email: 1147533288@qq.com
QQ: 1147533288