加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-12 15:15:55 所属栏目:百科 来源:网络整理
导读:建一个测试表和一个存储过程: [sql] view plain copy print ? create table a(a date ); create or replace procedure test as begin insert into a values (sysdate); end ; 定时任务样板: [sql] view plain copy print ? declare job1number; begin dbms
建一个测试表和一个存储过程: [sql] view plain copy print ?
  1. createtablea(adate);
  2. createorreplaceproceduretestas
  3. begin
  4. insertintoavalues(sysdate);
  5. end;


定时任务样板:

[sql] view plain copy print ?
  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;

查询定时任务: [sql] view plain copy print ?
  1. selectjob,broken,what,interval,t.*fromuser_jobst;


删除定时任务:

[sql] view plain copy print ?
  1. begin
  2. dbms_job.remove('24');
  3. commit;
  4. end;



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


启动定时任务:

[sql] view plain copy print ?
  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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读