单表大批量更新案例

   --摘自pinner的书,谢谢pinner.

update my_test set ftype=1 where ftype is null;

    如果表my_test有上百万条记录,可以分批更新,比如每1000条语句commit一次。

    declare

        row_num number :=0;
    begin
       for c_test in(select id from my_test t where ftype is null)loop
           update my_test t set t.ftype=1 where y.id=c_test.id;
           row_num :=row_num +1;
           --100条提交一次,可根据需要修改
           if mod(row_num,1000) =0 then
              commit;
           end if;

       end loop;
       commit;
    end;
    /
 
  需要关注undo和temp的使用情况:
     监控undo的剩余空间:
    select tablespace_name,round(sum(bytes)/(1024*1024),2) free_space
    from dba_free_space
    where tablespace_name='TBS_UNDO'
    group by tablespace_name;

   监控临时段的使用空间:
    
    select sum(nvl(blocks,0))*8/1024 MSIZE from v$sort_usage;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/543979/viewspace-714381/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/543979/viewspace-714381/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值