2
、 删除
可以考虑每
1W
条删一次,并注意脚本中的时间,根据实际情况来调整
方法一:
declare
cursor [del_cursor] is select a.*, a.rowid row_id from [table_name] a order
by a.rowid;
begin
for v_cusor in [del_cursor] loop
if v_cusor.[time_stamp] < to_date('2021-01-01','yyyy-mm-dd') then
delete from [table_name] where rowid = v_cusor.row_id;
end if;
if mod([del_cursor]%rowcount,10000)=0 then
commit;
end if;
end loop;
commit;
end;
/
变量说明:
[del_cursor]
游标名
[table_name]
你要删除数据的表名
[time_stamp]
你用作过滤条件的表的时间字段名称
方法二:
declare
maxrows number default 10000;
delete_ct number default 0;
begin
select count(1)/maxrows into delete_ct from [table_name] where
[time_stamp] < to_date('2017-01-01','yyyy-mm-dd');
for i in 1..TRUNC(delete_ct)+1
loop
delete [table_name] where [time_stamp] < to_date('2021-01-01','yyyy-mm-
dd') and rownum <= maxrows;
commit;
end loop ;
文档被以下合辑收录
评论