Home >Database >Mysql Tutorial >Oracle 调度程序学习

Oracle 调度程序学习

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:08:341005browse

Oracle中scheduler的管理主要是通过dbms_scheduler来执行。开始前的工作:创建一个用户:create user sched identified by oracl

Oracle中scheduler的管理主要是通过dbms_scheduler来执行。

开始前的工作:

创建一个用户:create user sched identified by oracle;

                           grant create session to sched;

                           grant scheduler_admin to sched;

使用用户hr登录数据库执行下面操作:

create table sched_test(dt  date,str  varchar2(32));

create or replace procedure p_scheduler_test
is
begin
   insert into hr.sched_test values(sysdate,'scheduler job test!');
   commit;
end;
/

把存储过程p_scheduler_test 执行权限赋予用户sched

grant execute on p_scheduler_test to sched;

 

 创建一个jobs

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name           =>  'INSERT_SCHED_TEST',
   job_type           =>  'STORED_PROCEDURE',
   job_action         =>  'HR.P_SCHEDULER_TEST',      //这里必须加上用户模式的限制
   start_date         =>  sysdate,
   repeat_interval    =>  'FREQ=MINUTELY;INTERVAL=1');
END;
/

可以通过表user_scheduler_jobs查看作业属性,,

查看SCHEDULER管理的JOB,可以通过USER_SCHEDULER_JOB_LOG和USER_SCHEDULER_JOB_RUN_DETAILS两个视图中查询。

执行命令:exec dbms_scheduler.enable('INSERT_SCHED_TEST');  使作业生效

执行命令:exec dbms_scheduler.disable('INSERT_SCHED_TEST'); 使作业失效

 执行命令:exec dbms_scheduler.set_attribute('job_name','job_attribute','new_value'); 更改作业相关属性。

手工执行作业:exec dbms_scheduler.run_job('job_name');

job、program和schedule的关系

program:指定要做的具体内容,也就是做什么

schedule:指定作业执行的时间和频率,也就是怎么做

job:指定要执行作业,就是做

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn