oracle 定时任务例子【项目例子】

        说明:请在plsql工具的命令窗口中,依次按步骤执行如下脚本
  
(1)建立备份表 my_test_log2
create table my_test_log2 as select * from my_test_log t where 1=2;

(2)创建索引
create index ind_userId on my_test_log2(userId);

(3)创建存储过程:每天移植数据到my_test_log2

CREATE OR REPLACE PROCEDURE MV_MY_TEST_LOG
AS 
BEGIN 
   insert into my_test_log2  
  select * from my_test_log t where t.leavetime is not null;
  delete from my_test_log t where t.leavetime is not null;
 commit;
END;
/
commit;

(4)创建oracle定时任务:-每天凌晨6:00点 : 执行存储过程

  declare
     job number;
    begin
      dbms_job.submit(job, 'MV_MY_TEST_LOG;', trunc(sysdate+1), 'TRUNC(SYSDATE + 1) + (6*60)/(24*60)');
    end;
/
commit;

   

 
 
 

posted @ 2013-07-26 10:23  嗨,你的益达~~~  阅读(267)  评论(0编辑  收藏  举报