首页 > 解决方案 > 每天插入和更新 400 万条记录

问题描述

审计目的,我想在一张表中插入100万条记录

并再次将 100 万条记录放入另一个表中。

并更新事务表(生产数据库)中的 100 万条记录,并再次更新

更新另一个事务表(生产数据库)中的 100 万条记录。

所以超过所有40M记录。等待资源时检测到错误 ORA-00060 死锁。

实际上我不能在交易之间做出承诺。成功完成任务后,我必须提交事务。例如,如果我为每个插入保持提交,任何错误都会发生我无法回滚。

我是甲骨文的新手。好心劝告。

提前致谢

流动

插入 1M

插入 1M

更新 1M

更新 1M

犯罪;

Create or replace procedure prc_tagbalance
As
Begin
  Insert into t1 
  Select custid,mobileno,openingbal,currentvalue
  From mas_walletinfo;
Exception
  -- Error table insert using procedurr with pragma Autonomous transaction
  Return;
End;

Begin
  Insert into t2
    Select vechileid,tid,tbalance from mas_vehicleinfo;
Exception
  --error table insert
  Return;
End;

Begin
  Update mas_walletinfo set openingbal=currentvalue;
Exception
  Return;
End;
Begin
  Update mas_vechileinfo set openingbal=tbalnce:
  Commit;
Exception
  Return;
End:
End;

标签: sqloracleplsqlsql-updatebulkinsert

解决方案


在每次操作后提交。

Create or replace procedure prc_tagbalance
As
Begin
  Insert into t1 
  Select custid,mobileno,openingbal,currentvalue
  From mas_walletinfo;
 Commit;
Exception
  -- Error table insert using procedurr with pragma Autonomous transaction
  Return;
End;

Begin
  Insert into t2
    Select vechileid,tid,tbalance from mas_vehicleinfo;
 Commit;
Exception
  --error table insert
  Return;
End;

Begin
  Update mas_walletinfo set openingbal=currentvalue;
 Commit;
Exception
  Return;
End;
Begin
  Update mas_vechileinfo set openingbal=tbalnce:
  Commit;
Exception
  Return;
End:
End;

推荐阅读