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;
  • 相关阅读:
    批量备份mysql数据库(shell编程)
    批量检查多个网址是否正常(shell编程)
    就linux三剑客简单归纳
    sql语句浅谈以及mysql遇到的问题解决见解
    linux shell每天一阅 -- 安装nginx以及apache
    Linux文件系统检查错误
    Linux账号管理和ACL
    简书博客
    Block内的强引用
    一次没有意义的优化
  • 原文地址:https://www.cnblogs.com/bulrush/p/7729409.html
Copyright © 2011-2022 走看看