排程管理大總結

lusklusklusk發表於2015-12-10

不管programschedulejob_classwindowwindow group怎麼去定義,最後都是為job服務的,即這些東西功能都是DBMS_SCHEDULER.CREATE_JOB所用到的一部分

 

Program:對所要執行的任務的描述

DBMS_SCHEDULER.CREATE_PROGRAM (

program_name IN VARCHAR2,

program_type IN VARCHAR2,

program_action IN VARCHAR2,

number_of_arguments IN PLS_INTEGER DEFAULT 0,

enabled IN BOOLEAN DEFAULT FALSE,

comments IN VARCHAR2 DEFAULT NULL);

 

 

schedule:對執行任務時的時間資訊的描述,比如時候開始,間隔時間,結束時間

DBMS_SCHEDULER.CREATE_SCHEDULE (

schedule_name IN VARCHAR2,

start_date IN TIMESTAMP WITH TIMEZONE DEFAULT NULL,

repeat_interval IN VARCHAR2,

end_date IN TIMESTAMP WITH TIMEZONE DEFAULT NULL,

comments IN VARCHAR2 DEFAULT NULL);

 

 

job:把Programschedule結合起來即任務(或job_classwindowwindow group結合起來)

Creates a job using a named schedule object and a named program object:

DBMS_SCHEDULER.CREATE_JOB (

job_name IN VARCHAR2,

program_name IN VARCHAR2,

schedule_name IN VARCHAR2,

job_class IN VARCHAR2 DEFAULT 'DEFAULT_JOB_CLASS',

enabled IN BOOLEAN DEFAULT FALSE,

auto_drop IN BOOLEAN DEFAULT TRUE,

comments IN VARCHAR2 DEFAULT NULL,

job_style IN VARCHAR2 DEFAULT 'REGULAR',

credential_name IN VARCHAR2 DEFAULT NULL,

destination_name IN VARCHAR2 DEFAULT NULL);

 

當然沒有programschedule也可以建立job的,具體做法是

Creates a job in a single call without using an existing program or schedule:

DBMS_SCHEDULER.CREATE_JOB (

job_name IN VARCHAR2,

job_type IN VARCHAR2,

job_action IN VARCHAR2,

number_of_arguments IN PLS_INTEGER DEFAULT 0,

start_date IN TIMESTAMP WITH TIME ZONE DEFAULT NULL,

repeat_interval IN VARCHAR2 DEFAULT NULL,

end_date IN TIMESTAMP WITH TIME ZONE DEFAULT NULL,

job_class IN VARCHAR2 DEFAULT 'DEFAULT_JOB_CLASS',

enabled IN BOOLEAN DEFAULT FALSE,

auto_drop IN BOOLEAN DEFAULT TRUE,

comments IN VARCHAR2 DEFAULT NULL,

credential_name IN VARCHAR2 DEFAULT NULL,

destination_name IN VARCHAR2 DEFAULT NULL);

 

schedule_nameThe name of the schedule, window, or window group associated with this

job.

 

auto_drop This flag, if TRUE, causes a job to be automatically dropped after it has

completed or has been automatically disabled. A job is considered

completed if:

Its end date (or the end date of the job schedule) has passed.

It has run max_runs number of times. max_runs must be set with SET_

ATTRIBUTE.

It is not a repeating job and has run once.

 

DBMS_SCHEDULER.SET_ATTRIBUTE (

name IN VARCHAR2,

attribute IN VARCHAR2,

value IN VARCHAR2,

value2 IN VARCHAR2 DEFAULT NULL);

 

attribute max_runs This attribute specifies the maximum number of consecutive scheduled

runs of the job. Once max_runs is reached, the job is disabled and its state

is changed to COMPLETED.

max_runs can be an integer between 1 and 1,000,000. By default, it is set to

NULL, which means that it repeats forever or until end_date or max_

failures is reached.

 

 

 

Job class:用來將若干個相關的任務關聯起來作為一個組,一般與某個資源使用者組或service關聯(資源使用者組和service只能關聯一個,不能同時關聯兩者)

DBMS_SCHEDULER.CREATE_JOB_CLASS (

job_class_name IN VARCHAR2,

resource_consumer_group IN VARCHAR2 DEFAULT NULL,

service IN VARCHAR2 DEFAULT NULL,

logging_level IN PLS_INTEGER DEFAULT DBMS_SCHEDULER.LOGGING_RUNS,

log_history IN PLS_INTEGER DEFAULT NULL,

comments IN VARCHAR2 DEFAULT NULL);

 

 

Window:表示一個時間段,比如早上8點到下午6點可以為一個windowwindow可以與某個計劃關聯也可以與某個schedule關聯(兩者可同時關聯),其實作用就是一個schedule

Creates a window using a named schedule object:

DBMS_SCHEDULER.CREATE_WINDOW (

window_name IN VARCHAR2,

resource_plan IN VARCHAR2,

schedule_name IN VARCHAR2,

duration IN INTERVAL DAY TO SECOND,

window_priority IN VARCHAR2 DEFAULT 'LOW',

comments IN VARCHAR2 DEFAULT NULL);

Creates a window using an inlined schedule:

DBMS_SCHEDULER.CREATE_WINDOW (

window_name IN VARCHAR2,

resource_plan IN VARCHAR2,

start_date IN TIMESTAMP WITH TIME ZONE DEFAULT NULL,

repeat_interval IN VARCHAR2,

end_date IN TIMESTAMP WITH TIME ZONE DEFAULT NULL,

duration IN INTERVAL DAY TO SECOND,

window_priority IN VARCHAR2 DEFAULT 'LOW',

comments IN VARCHAR2 DEFAULT NULL);

 

Window group:把若干個相關的window關聯起來,作為一個組,其實作用就是一個schedule

DBMS_SCHEDULER.CREATE_WINDOW_GROUP (

group_name IN VARCHAR2,

window_list IN VARCHAR2 DEFAULT NULL,

comments IN VARCHAR2 DEFAULT NULL);

group_name就是windows group的名稱,window_list就是window的名稱,多個window則用逗號隔開


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30126024/viewspace-1869832/,如需轉載,請註明出處,否則將追究法律責任。

相關文章