- createtablea(adate);
- createorreplaceproceduretestas
- begin
- insertintoavalues(sysdate);
- end;
定时任务样板:
- declare
- job1number;
- begin
- dbms_job.submit(job1,
- what=>'test;',
- next_date=>sysdate,
- interval=>'sysdate+1/(24*60*60)');--每隔1s处理一次用户表
- commit;
- end;
查询定时任务:
- selectjob,broken,what,interval,t.*fromuser_jobst;
删除定时任务:
- begin
- dbms_job.remove('24');
- commit;
- end;
- Interval=>TRUNC(sysdate+1)--每天凌晨0点执行
- Interval=>TRUNC(sysdate+1)+1/24--每天凌晨1点执行
启动定时任务:
- begin
- dbms_job.run(24);--24jodid
- --commit;
- end;
create or replace procedure backUpDayMessage as begin insert into t_call_message_2017 select * from t_Call_Message t where to_char(t.visit_time,'YYYYMMDD') = to_char(TRUNC(sysdate - 1),'YYYYMMDD'); end; declare backUpDayMessageJob number; begin dbms_job.submit(backUpDayMessageJob,what => 'backUpDayMessage;',next_date => TRUNC(sysdate) + 1,interval => 'TRUNC(SYSDATE) +1+ 1 / 24'); commit; end;