您好,登錄后才能下訂單哦!
1.該表很大,8t,由三列,其中create_time,現在要求修改成非空值,由于數據量比較大,因此采用分批來增加。
腳本如下
create or replace procedure PRC_UPDATE_CREATE_TIME is
start_num integer;
start_date date;
total number;
update_count integer;
per_loop_count integer;
begin
dbms_output.put_line('Start to batch update');
start_num := 1; -- start value of cycle
per_loop_count := 100; -- per cycle handle count
start_date := to_date('20100101', 'YYYYMMDD'); -- start date of create_time
/ get total number of the update records /
select count(1) into total from tmp_loan_file_data
where CREATE_TIME is null;
dbms_output.put_line('total number:');
dbms_output.put_line(total);
update_count := total/per_loop_count;
if (mod(total, per_loop_count) > 0) then
update_count := update_count + 1;
end if;
dbms_output.put_line('loop times:');
dbms_output.put_line(update_count);
/ Loop to update records /
while start_num <= update_count loop
dbms_output.put_line('loop seq :');
dbms_output.put_line(start_num);
merge into tmp_loan_file_data src_tab
using (select t.rowid as rid
from tmp_loan_file_data t
where t.CREATE_TIME is null
and rownum >=1
and rownum <= per_loop_count) sel_tmp
on (src_tab.rowid = sel_tmp.rid)
when matched then
update set CREATE_TIME = start_date;
start_num := start_num + 1;
start_date := start_date + 1;
commit;
end loop;
dbms_output.put_line('End batch update');
end PRC_UPDATE_CREATE_TIME;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。