解决方案 »

  1.   

    如果这个字段精确到分秒,
    你这种方法很有可能导致AA表的数据不能完全备份到bb表。
      

  2.   

    楼主这写法应该没啥问题,楼主先将时间读取到变量里了
    insert和delete两个语句的where语句取到的时间也应该是一致的
    这么写没什么问题
      

  3.   

    语句中加上 HINT 如,APPEND
    若该动作发生在业务很空闲的时间段里,也可以考虑增加 并行
      

  4.   

    如果这个字段精确到分秒,
    你这种方法很有可能导致AA表的数据不能完全备份到bb表。这个字段确实精确到秒了,请问是不是因为job执行的时刻导致不能完全备份?
      

  5.   

    楼主这写法应该没啥问题,楼主先将时间读取到变量里了
    insert和delete两个语句的where语句取到的时间也应该是一致的
    这么写没什么问题
    谢谢,可是总觉得哪里不对
      

  6.   

    该动作在凌晨4点执行,几乎没有数据进入。能具体说说并行怎么来操作吗?insert /* APPEND PARALLEL(BB,4) */ into BB select  /*  PARALLEL(BB,4) */ * from AA where AA.loadtime<temp_date;
    delete /* APPEND PARALLEL(BB,4) * from AA where loadtime<temp_data;
      

  7.   

    如果这个字段精确到分秒,
    你这种方法很有可能导致AA表的数据不能完全备份到bb表。这个字段确实精确到秒了,请问是不是因为job执行的时刻导致不能完全备份?
    对啊,如果你的job执行时刻有问题,可能导致取到的sysdate有问题,导致有些记录漏掉。
    建议你将时间变量的时分秒固定
      

  8.   

    zlloct说的对,楼主最好设定好固定时间。
    由于job执行时间问题,最好类似于这样设定:
    select trunc(sysdate-30) into temp_date from dual;
      

  9.   

    你这样做功能可能没有问题,但效率肯定会很低的,数据量很大,在delete大量数据库是,会产生redo 日志和需要很大undo表空间
      

  10.   

    如果这个字段精确到分秒,
    你这种方法很有可能导致AA表的数据不能完全备份到bb表。这个字段确实精确到秒了,请问是不是因为job执行的时刻导致不能完全备份?
    对啊,如果你的job执行时刻有问题,可能导致取到的sysdate有问题,导致有些记录漏掉。
    建议你将时间变量的时分秒固定
    恩,不错的建议,谢啦!!☆⌒(*^-゜)v
      

  11.   

    性能问题:
    insert into BB select * from AA where AA.loadtime<temp_date;
    delete from AA where loadtime<temp_data;
    因为数量很大,最好在loadtime 要有索引
    对于删除表中大批量数据库delete from AA where loadtime<temp_data; 建议改成存储过程批量删除 2万条提交一次。例如如下
    create or replace procedure wwdelete_table
    is
    i number(10);
    row varchar2(60);
    cursor cur is select rowid from AA where loadtime<temp_data;
    begin
    open cur;
    loop
    fetch cur into row;
    execute immediate 'delete from AA where rowid=:1'
            using row;
    i:=i+1;
    if i>20000 then
    commit;
    i:=0;
    end if;
    exit when cur%notfound;
    end loop;
    commit;
    close cur;
    exception
    when others then
    rollback;
    end wwdelete_table;
    这样会比一条delete语句删除效率高很多
      

  12.   

    最好是分批提交,你这一下子insert into BB select * from AA where AA.loadtime<temp_date;
    delete from AA where loadtime<temp_data;可能会引起 undo 暴涨,每次只导 1W 条,按 PK 区分。
      

  13.   

    批量删除的话可以使用bulk into的用法
      

  14.   

    批量删除的话可以使用bulk into的用法
    我再研究下,感谢