zoukankan      html  css  js  c++  java
  • Oracle定时器

    实现步骤: 
      1.创建一个测试表 
    create table test(dTime date); 
      
      2.创建一个存储过程 
    create or replace procedure p_test as 
    begin 
    insert into test values(sysdate); 
    end; 
    
      3.创建执行计划:每小时运行一次存储过程 
    Declare 
      i Integer; 
    Begin 
       dbms_job.submit(i,'p_test;',Sysdate,'sysdate+1/24'); 
    end; 
    

    4.运行执行计划 Declare jobno Integer; Begin -- 查找计划号 Select t.JOB into jobno From User_Jobs t where t.JOB='45'; -- 运行制定的执行计划 dbms_job.run(jobno); end; 5.查看任务队列情况 select job,next_date,next_sec,failures,broken from user_jobs; 6.查看任务执行情况 select to_char(dTime ,'yyyy/mm/dd hh24:mi:ss') from test order By dTime; 7.停止执行计划 Declare jobno Integer; Begin -- 查找计划号 Select t.JOB into jobno From User_Jobs t where t.JOB='45'; -- 停止计划,不再继续执行 --dbms_job.broken(jobno,True); -- 停止计划,并在两分钟后继续执行 dbms_job.broken(jobno,True,Sysdate+(2/24/60)); end; 8.删除执行计划 Declare jobno Integer; Begin -- 查找计划号 Select t.JOB into jobno From User_Jobs t where t.JOB='45'; dbms_job.remove(jobno); end; 9.修改执行计划 Declare jobno Integer; Begin -- 查找计划号 Select t.JOB into jobno From User_Jobs t where t.JOB='45'; -- 修改为:每分钟执行一次 dbms_job.interval(jobno, 'sysdate+1/(24*60)'); end;
  • 相关阅读:
    从零搭建springboot+mybatis逆向工程
    基础SQL总结
    Map集合浅谈
    ArrayList、LinkedList与Vector的区别
    java多线程总结
    P4108 [HEOI2015]公约数数列
    P2168 [NOI2015] 荷马史诗
    正睿 2021 Noip 十连测 Day2
    CF772E Verifying Kingdom
    BZOJ1767 [CEOI2009] Harbingers
  • 原文地址:https://www.cnblogs.com/bulrush/p/7729409.html
Copyright © 2011-2022 走看看