批量删除海量数据通常都是很复杂及缓慢的,方法也很多,但是通常的概念是:分批删除,逐次提交.
下面是删除过程,数据表可以通过主键删除,测试过delete与for all两种方法,for all在这里并没有带来性能提高,所以仍然选择了批量直接删除.
create or replace procedure delbigtab 【程序编程相关:Microsoft Visual Stu】
首先创建一下过程,使用自制事务进行处理: 【推荐阅读:Microsoft MSDTC TIP 】
【扩展信息:微软 DirectX DirectSho】 ( p_tablename in varchar2, p_condition in varchar2, p_count in varchar2 ) as pragma autonomous_transaction; n_delete number:=0; begin while 1=1 loop execute immediate delete from ||p_tablename|| where ||p_condition|| and rownum <= :rn using p_count; if sql%notfound then exit; else n_delete:=n_delete + sql%rowcount; end if; commit; end loop; commit; dbms_output.put_line(finished!); dbms_output.put_line(totally ||to_char(n_delete)|| records deleted!); ... 下一页