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;
  • 相关阅读:
    数据库的未来:ORM+LINQ+RX
    工具论-科学是实用工具
    事务、锁与原子性
    ORM-面向对象&关系数据库
    swift Class的内存布局
    使用phpexcel导出到xls文件的时候出现乱码解决
    苹果CMS
    js网页如何获取手机屏幕宽度
    常用正则说明
    php中的线程、进程和并发区别
  • 原文地址:https://www.cnblogs.com/bulrush/p/7729409.html
Copyright © 2011-2022 走看看