oracle起定时任务,每隔1秒执行一次

前端之家收集整理的这篇文章主要介绍了oracle起定时任务,每隔1秒执行一次前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
建一个测试表和一个存储过程:
  1. createtablea(adate);
  2. createorreplaceproceduretestas
  3. begin
  4. insertintoavalues(sysdate);
  5. end;


定时任务样板:

  1. declare
  2. job1number;
  3. begin
  4. dbms_job.submit(job1,
  5. what=>'test;',
  6. next_date=>sysdate,
  7. interval=>'sysdate+1/(24*60*60)');--每隔1s处理一次用户
  8. commit;
  9. end;

查询定时任务:
  1. selectjob,broken,what,interval,t.*fromuser_jobst;


删除定时任务:

  1. begin
  2. dbms_job.remove('24');
  3. commit;
  4. end;



  1. Interval=>TRUNC(sysdate+1)--每天凌晨0点执行@H_502_292@
  2. Interval=>TRUNC(sysdate+1)+1/24--每天凌晨1点执行@H_502_292@


启动定时任务:

  1. begin
  2. dbms_job.run(24);--24jodid
  3. --commit;
  4. 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;

猜你在找的Oracle相关文章