zoukankan      html  css  js  c++  java
  • Sybase数据库超大表数据矫正更新

    问题背景

    随着数据的增长,系统中过千万的业务表在已经不少见。对这些超大表进行矫正更新时,直接update会产生大量的事务日志,撑爆日志空间,导致事务回滚矫正失败。

    解决问题

    解决问题的思路就是分批提交减少事务日志的大小,其中一种方法是在存储过程中使用游标更新并批量提交。

    代码如下:

    use YWST
    go
    
    --创建更新存储过程,更新10000行提交一次
    create procedure update_sfgd
    as 
    declare update_cur cursor for select N_SFGD FROM YWST..T_YWGY_DZJZ_JZML for update of N_SFGD   
    declare  @update_count int,@sfgd int  
    
    begin
       set @update_count = 0
       open  update_cur
       fetch update_cur into @sfgd
       while (@@sqlstatus != 2)
       begin
            update YWST..T_YWGY_DZJZ_JZML set N_SFGD = 1 where current of update_cur
            set @update_count = @update_count +1
            if @update_count = 10000
            begin
                   commit
                   set @update_count = 0
            end
            fetch update_cur into @sfgd
       end 
       close update_cur
    end
    go
    
    -- 执行更新存储过程
    exec update_sfgd
    go
    
    
  • 相关阅读:
    JavaScript跨域总结与解决办法
    css IFC 与 BFC分析
    JavaScript Note
    Knowledge Architecture
    BSP
    Olympiad
    Software Engineering
    Assembly Language
    Algorithm
    Data Structure
  • 原文地址:https://www.cnblogs.com/wangzhen3798/p/7630599.html
Copyright © 2011-2022 走看看