oracle大数据量迁移,分批量导入样例(fetch...bulk collect)以及forall结合使用

//插入时不产生日志,
alter table IALHospitalInfo nologging;
//记录时间
set timing on;
declare

    CURSOR cur is 
         select 
             nvl(c.claim_code,c.claim_id) as claim_code,
            case when (select u.user_name  from T_CIRC_USER u ,T_THIRD_POLICY p where u.user_id =p.user_id and  p.CONFIRM_SEQUENCE_NO = c.Confirm_Sequence_No) is null then 'aaaa' 
                   else
                      (select u.user_name  from T_CIRC_USER u ,T_THIRD_POLICY p where u.user_id =p.user_id and  p.CONFIRM_SEQUENCE_NO = c.Confirm_Sequence_No)            
            end,
            '110000',
            perl.person_id,
            hos.hos_id,
            case when (select t.Na_Company_Code from T_CIRC_COMPANY t where t.Company_Id = c.Company_Id) is null then 'aaaa'  
                   else
                      (select t.Na_Company_Code from T_CIRC_COMPANY t where t.Company_Id = c.Company_Id)        
            end,
            hos.Hospital_Name,
            hos.Hospital_Factory_Certi_Code
     from CIITC_TMP_T_C_L c , T_CLAIM_PERSON_LOSS perl ,t_claim_person_hospital hos where hos.hos_id  in (select v.hos_id from t_claim_person_hospital v) and c.claim_id = hos.claim_id and perl.person_id = hos.person_id;         
    type rec is table of IALHospitalInfo%rowtype;
    recs rec;
begin
    open cur;
    while (true) loop
        //批量提交控制(每100w提交一次)
        fetch cur bulk collect into recs limit 1000000;
        //捆绑插入(减少与服务器交互的次数)
        forall i in 1..recs.count insert /*+ append */into IALHospitalInfo values recs(i);  
    commit;
    exit when cur%notfound;
end loop;
close cur;
end;
/
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值