27使用调度程序

Oracle Database provides database job capabilities through Oracle Scheduler (the Scheduler). This chapter explains how to use the various Scheduler components, and discusses the following topics:

调度程序对象和它们的命名

使用Jobs

使用Programs

使用Schedules

使用Job Classes

使用Windows

使用Window Groups

使用Events

使用Chains

分配资源通过jobs

Note:

This chapter describes how to use the DBMS_SCHEDULER package to work with Scheduler components. You can accomplish the same tasks using Oracle Enterprise Manager.

使用jobs

一个job是一个调度和一个程序的结合,还有额外的被程序要求的参数。这一部分给你介绍了基本的job任务和讨论下列主题:

Job任务和他们的存储过程

创建jobs

复制jobs

修改jobs

运行jobs

停止jobs

仍掉jobs

关闭jobs

开启jobs

See Also:

"Jobs" for an overview of jobs.

创建Jobs

你可以创建jobs使用CREATE_JOB存储过程或者EM.当创建一个job,你可以指定一个动作,一个schedule,和其他属性。例如,下列的语句创建了一个job叫做update_sales,调用了一个存储的存储过程在OPS模式中来更新一个sales概览表:

BEGIN

DBMS_SCHEDULER.CREATE_JOB (

job_name           =>  'update_sales',

job_type           =>  'STORED_PROCEDURE',

job_action         =>  'OPS.SALES_PKG.UPDATE_SALES_SUMMARY',

start_date         =>  '28-APR-03 07.00.00 PM Australia/Sydney',

repeat_interval    =>  'FREQ=DAILY;INTERVAL=2', /* every other day */

end_date           =>  '20-NOV-04 07.00.00 PM Australia/Sydney',

job_class          =>  'batch_update_jobs',

comments           =>  'My new job');

END;

/

你能创建一个job以另外一个schema通过指定schema.job_name.因此,一个job的创建者不一定是job的属主。Job的属主是job被创建的模式对应那个用户,job创建者时正在创建job的用户。Job被创建使用job被创建的schema的权限。Job运行时的NLS环境变量是job被创建那一时刻被呈现的NLS环境变量。

After a job is created, it can be queried using the *_SCHEDULER_JOBS views. Jobs are created disabled by default and need to be enabled to run.

Jobs are set to be automatically dropped by default after they complete. Setting the auto_drop attribute to FALSE causes the job to persist. Note that repeating jobs are not auto-dropped unless the job end date passes, the maximum number of runs (max_runs) is reached, or the maximum number of failures is reached (max_failures).

Ways of Creating Jobs

You create a job using the CREATE_JOB procedure or Enterprise Manager. Because this procedure is overloaded, there are several different ways of using it. In addition to inlining a job during the job creation, you can also create a job that points to a named program and schedule. This is discussed in the following sections:

Creating Jobs Using a Named Program

You can also create a job by pointing to a named program instead of inlining its action. To create a job using a named program, you specify the value for program_name in the CREATE_JOB procedure when creating the job and do not specify the values for job_type, job_action, and number_of_arguments.

To use an existing program when creating a job, the owner of the job must be the owner of the program or have EXECUTE privileges on it. An example of using the CREATE_JOB procedure with a named program is the following statement, which creates a job called my_new_job1:

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name          =>  'my_new_job1',
   program_name      =>  'my_saved_program', 
   repeat_interval   =>  'FREQ=DAILY;BYHOUR=12',
   comments          =>  'Daily at noon');
END;
/
Creating Jobs Using a Named Schedule

You can also create a job by pointing to a named schedule instead of inlining its schedule. To create a job using a named schedule, you specify the value for schedule_name in the CREATE_JOB procedure when creating the job and do not specify the values for start_date, repeat_interval, and end_date.

You can use any named schedule to create a job because all schedules are created with access to PUBLIC. An example of using the CREATE_JOB procedure with a named schedule is the following statement, which creates a job called my_new_job2:

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name                 =>  'my_new_job2', 
   job_type                 =>  'PLSQL_BLOCK',
   job_action               =>  'BEGIN SALES_PKG.UPDATE_SALES_SUMMARY; END;',
   schedule_name            =>  'my_saved_schedule');
END;
/
Creating Jobs Using a Named Program and Schedule

A job can also be created by pointing to both a named program and schedule. An example of using the CREATE_JOB procedure with a named program and schedule is the following statement, which creates a new job called my_new_job3 based on the existing program my_saved_program1 and the existing schedule my_saved_schedule1:

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name            =>  'my_new_job3', 
   program_name        =>  'my_saved_program1', 
   schedule_name       =>  'my_saved_schedule1');
END;
/

Copying Jobs

You copy a job using the COPY_JOB procedure or Enterprise Manager. This call copies all the attributes of the old job to the new job except the new job is created disabled and has another name.

See Oracle Database PL/SQL Packages and Types Reference for detailed information about the COPY_JOB procedure.

Altering Jobs

You alter a job using the SET_ATTRIBUTE procedure or Enterprise Manager. All jobs can be altered, and, with the exception of the job name, all job attributes can be changed. If there is a running instance of the job when the SET_ATTRIBUTE call is made, it is not affected by the call. The change is only seen in future runs of the job.

In general, you should not alter a job that was automatically created for you by the database. Jobs that were created by the database have the column SYSTEM set to TRUE in job views. The attributes of a job are available in the *_SCHEDULER_JOBS views.

It is perfectly valid for running jobs to alter their own job attributes using the SET_ATTRIBUTE procedure, however, these changes will not be picked up until the next scheduled run of the job.

See Oracle Database PL/SQL Packages and Types Reference for detailed information about the SET_ATTRIBUTE procedure and "Configuring the Scheduler".

Oracle 10.2数据库管理员指南-27章的更多相关文章

  1. ORACLE数据库管理员的职责

    ORACLE数据库管理员的职责 一.概述 ORACLE数据库管理员应按如下方式对ORACLE数据库系统做定期监控: (1). 每天对ORACLE数据库的运行状态,日志文件,备份情况,数据库的空间使用情 ...

  2. Oracle数据库管理员面试题

    Oracle数据库管理员面试题 1.模拟使用oracle的flashback找回过去某个时间点的数据,实现误操作的恢复. http://www.txw100.com/soft/2013/08/547. ...

  3. 第一章 数据库管理员(DBA)

    一.DBA的工作 1.初级:mysql基础安装.搭建 2.中级:数据库管理员DBA 1)用户管理 1.用户的权限2.用户可以操作的库或者表3.用户名和来源的主机4.用户的密码​grant all on ...

  4. oracle数据库管理员简介、导入数据与导出数据

    数据库管理员: sys和system的权限区别:sys:所有oracle的数据字典的基表和视图都存放在sys用户中,这些基表和视图对于oracle的运行时至关重要的,由数据库 自己维护,任何用户都不能 ...

  5. 十一、oracle 数据库管理员

    一.数据库管理员每个oracle数据库应该至少有一个数据库管理员(dba),对于一个小的数据库,一个dba就够了,但是对于一个大的数据库可能需要多个dba分担不同的管理职责.那么一个数据库管理员的主要 ...

  6. oracle 数据库管理员

    一.数据库管理员每个oracle数据库应该至少有一个数据库管理员(dba),对于一个小的数据库,一个dba就够了,但是对于一个大的数据库可能需要多个dba分担不同的管理职责.那么一个数据库管理员的主要 ...

  7. Oracle 数据库管理员及管理员的作用

    以下测试实例均在Oracle11gr2下测试!!! 一.简介:每个Oracle数据库应该至少有一名数据库管理员(dba),对于一个小的数据库,一个dba就够了,但是对于一个大的数据库,可能需要多个db ...

  8. 如何成为一名出色的Oracle数据库管理员

    主要针对Oracle DBA在成长阶段的定位,学习方法等几大方面进行了经典的论述,详细内容请参考下文. 一.定位 Oracle分两大块,一块是开发,一块是管理.开发主要是写写存储过程.触发器什么的,还 ...

  9. 统一者管理员指南(Unifier Administration Guide)中文

    统一者管理员指南 Unifier Administration Guide 2014年6月 发布 2014年11月翻译 10.0版本 10.0.1译 关于译者 翻译者QQ:77811970 Email ...

随机推荐

  1. ucos_ii 上锁函数OSSchedLock()函数透析

    因为任务调度时一般都是通过OSTIMEDLY()来实现.在这个函数中会对当前的任务执行挂起.同时查看任务调度表中是否有优先级合适的就绪任务.如果当前任务运行时调用OSSchedLock()给调度器上锁 ...

  2. 树莓派入门教程——使用Qt开发界面程序

    前言        Qt是一个1991年由奇趣科技开发的跨平台C++图形用户界面应用程序开发框架.它既可以开发GUI程序,也可用于开发非GUI程序,比如控制台工具和服务器.Qt是面向对象的框架,使用特 ...

  3. Linq to object 技巧、用法集锦

    一.一个字符串,一个字符串数组.判断字符串数组里的元素出现在字符串中的有几个. class Program { static void Main(string[] args) { string str ...

  4. Qt编程之在QGraphics scene中使用图片

    http://stackoverflow.com/questions/5960074/qimage-in-a-qgraphics-scene http://stackoverflow.com/ques ...

  5. 为什么Linux不需要碎片整理?

    如果你是一个 Linux 用户,你可能会听说 Linux 的文件系统不需要碎片整理.你也可能会注意到 Linux 的发行版本也都没有磁盘碎片整理的功能.这是为什么呢? 要理解为什么 Linux 的文件 ...

  6. dos判断系统版本

    可以通过VER命令的输出结果判断2K/XP/NT,楼主应该对比以下各版本的VER命令输出结果,参考MrPotter(HarryPotter) 的脚本即可, ver|find "XP" ...

  7. <转载>C++的链接错误LNK2005

    转载http://bbs.csdn.net/topics/70346371 编程中经常能遇到LNK2005错误——重复定义错误,其实LNK2005错误并不是一个很难解决的错误.弄清楚它形成的原因,就可 ...

  8. WPF - 如何引用external dll中图片

    前几天一直想引用别的DLL里面的一个图片.总是出现各种各样问题,一气之下将图片拷贝到当前Project中,运行良好.虽然知道引用图片,就1.2.列出来的2点就够了. 1. The Build Acti ...

  9. Mysql--mysqldump命令 备份数据库

    mysqldump命令用来备份数据库. mysqldump命令在DOS的[url=file://\\mysql\\bin]\\mysql\\bin[/url]目录下执行. 1) 导出整个数据库(导出文 ...

  10. Unity 3D 动画帧事件

    前几天在项目开发中碰到一个这样的需求,RPG游戏中,特效和动画播放不同步的.假如主角在攻击NPC时,先实例化特效,后播放动画.动画毕竟是有一个时间长度的.等到动画播放攻击挥刀的那一瞬间时,特效可能早就 ...