Oracle千万级数据处理

--插入时不产生日志,
--alter table cux_mtl_material_vmi2024038 nologging;
--记录时间
--set timing on;
复制代码
declare
  cursor cur is
    select mmt.organization_id,
           mmt.subinventory_code,
           mmt.transaction_quantity,
           mmt.transfer_organization_id,
           mmt.transfer_subinventory,
           mmt.owning_organization_id,
           mmt.xfr_owning_organization_id,
           mmt.inventory_item_id,
           mmt.transaction_id,
           mmt.transaction_date,
           sysdate
    -- mmt.creation_date
      from mtl_material_transactions mmt
     where mmt.transaction_type_id = 74
       and mmt.owning_organization_id in
           (select org.organization_id from org_organization_definitions org);
  type rec is table of cux_mtl_material_vmi2024038%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(6) */
      into cux_mtl_material_vmi2024038
      values recs(i);
    commit;
    exit when cur%notfound;
  end loop;
  close cur;
end;
复制代码

 

posted @   Iven_lin  阅读(42)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示