记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。



1,创建新表gps-sq ,保存查询出来表名的rownum 值。

#:  create table gps_sq as select *
              from (select rownum sq , tname
                      from tab
                     where tname like 'GPS_HT_%'
                     order by tname)

2,新建存储过程。


create or replace procedure p_del_gps_ht(a in number,b in number) is
  t_sql varchar2(2000);
begin
  for c in (select tname
              from gps_sq
             where sq >= a
               and sq <= b) loop
 t_sql:='delete from  '||c.tname||' where to_char(location_time,''yyyymmdd'')<=''20140731''';
    execute immediate t_sql;
    commit;
  end loop;
end p_del_gps_ht;


3,执行过程,分批删除数据。


#: execute p_del_gps_ht(1,500)



转载请标明出处【oracle 分批删除大量表中数据方法】。

《www.micoder.cc》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论