首页 > Linux操作系统 > Linux操作系统 > 关于Oracle大批量删除数据
用procedure来实现:
create or replace procedure delTab
(
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!');
end;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/658698/viewspace-310124/ ,如需转载,请注明出处,否则将追究法律责任。