waterye

使用DBMS_SCHEDULER定时执行任务

The DBMS_JOB package has been superseded by the DBMS_SCHEDULER package.

create job
BEGIN
  DBMS_SCHEDULER.CREATE_JOB(job_name      
=> 'delete_goods_job',
                            job_type      
=> 'STORED_PROCEDURE',
                            job_action    
=> 'delete_goods',
                            repeat_interval 
=> 'FREQ=SECONDLY; INTERVAL=6',
                            enabled       
=> true,
                            comments      
=> 'delete goods data'                  
                            );
END;
/
drop job
BEGIN
    DBMS_SCHEDULER.DROP_JOB(job_name 
=> 'delete_goods_job'); 
END;
/
disable job
BEGIN
    DBMS_SCHEDULER.DISABLE(name 
=> 'delete_goods_job'); 
END;
/
enable job
BEGIN
    DBMS_SCHEDULER.ENABLE(name 
=> 'delete_goods_job'); 
END;
/
select jobs
select * from USER_SCHEDULER_JOBS;
query logs(感谢itpub的teddyboy)
select * from ALL_SCHEDULER_JOB_RUN_DETAILS
where owner = 'SCOTT'
order by log_date desc
delete logs
delete from ALL_SCHEDULER_JOB_RUN_DETAILS
where owner = 'SCOTT'

参考:
1. PL/SQL Packages and Types Reference
2. http://www.itpub.net/378320.html

posted on 2005-12-30 18:42 waterye 阅读(1506) 评论(0)  编辑  收藏 所属分类: oracle


只有注册用户登录后才能发表评论。


网站导航: