Oracle每10天删除数据,并重建索引

declare
datDateFrom date := to_date('2010/08/01 00:00:00','yyyy/mm/dd hh24:mi:ss');
datDateTo date;
begin
while datDateFrom <to_date('2014/01/01 00:00:00','yyyy/mm/dd hh24:mi:ss')
loop
datDateTo := least(datDateFrom + 10,to_date('2014/01/01 00:00:00','yyyy/mm/dd hh24:mi:ss')); INSERT INTO DRMARCHIVE.DBPROCLOG
select createdate,pgm,status from dbproclog where createdate >= datDateFrom and createdate < datDateTo; delete from dbproclog where createdate >= datDateFrom and createdate < datDateTo;
commit;
Insertlog(SYSDATE, 'dbproclog_delete', to_char(datDateFrom,'yyyy/mm/dd hh24:mi:ss') || ' to ' || to_char(datDateTo,'yyyy/mm/dd hh24:mi:ss') || ' deleted');
DBMS_LOCK.SLEEP(2); datDateFrom := datDateTo;
end loop; execute immediate 'alter index DBPROCLOG_IDX2 rebuild ONLINE';
execute immediate 'alter index DBPROCLOG_IDX1 rebuild ONLINE';
end;
上一篇:团队作业4——第一次项目冲刺 FiRsT DaY


下一篇:安装Oracle11g时,检测到系统的主 IP 地址是 DHCP 分配的地址