update t_scenotesatisfylog a set a.serviceid = (select t.serviceid from t_sceinvitelog t
where a.entertime<=t.entertime+2/1440
and a.entertime>= t.entertime
and a.serviceno = t.serviceno
and t.entertime<sysdate
and rownum=1)已上代码为研发提供,思路为全表更新,但是现场数据库可能受不了这样的操作,并且量太大,中途不能中断,麻烦有无大侠给个修改后的脚本,最好能够按月来跑,这样对数据库影响小点,另外逼人在电信工作,对客户影响较小。十万火急,谢谢..............

解决方案 »

  1.   

    先按时间条件select一把,然后确定采用多长的时间段去更新,比如50万一批进行操作.
      

  2.   

    DECLARE
     
    BEGIN
     
      FOR i IN (SELECT t.serviceno, t.serviceid, t.entertime
                  FROM t_sceinvitelog t
                 WHERE t.entertime >= to_date('2008-08-29', 'yyyy-mm-dd')
                   AND t.entertime < to_date('2008-08-30', 'yyyy-mm-dd')) LOOP
      
        UPDATE t_scenotesatisfylog a
           SET a.serviceid = i.serviceid
         WHERE a.entertime >= to_date('2008-08-29', 'yyyy-mm-dd')
           AND a.entertime < to_date('2008-08-30', 'yyyy-mm-dd')
           AND a.serviceno = i.serviceno
           AND a.entertime = i.entertime;
      
      END LOOP;
     
    END;
    /能否优化,我快疯了