CREATE_SCHEDULE Procedure
This procedure creates a 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);
|
The name to assign to the schedule. The name must be unique in the SQL namespace. For example, a schedule cannot have the same name as a table in a schema. If no name is specified, then an error occurs. 名稱唯一,必須指定!! |
|
This attribute specifies the first date and time on which this schedule becomes valid. For a repeating schedule, the value for
If If 該參數指定了什麼時候開始schedule。對於重複的時間 取決於第一次實例化的schedule |
|
This attribute specifies how often the schedule repeats. It is expressed using calendaring syntax. See "Calendaring Syntax" for further information. PL/SQL expressions are not allowed as repeat intervals for named schedules. 該參數決定schedule執行的週期 具體用法在下文中列出 |
|
The date and time after which jobs will not run and windows will not open. A non-repeating schedule that has no
|
|
This attribute specifies an optional comment about the schedule. By default, this attribute is
|
注意:權限問題
This procedure requires the CREATE
JOB
privilege to create a schedule in your own schema or the
CREATE
ANY
JOB
privilege to create a schedule in someone else's schema by specifying
schema.schedule_name
. Once a schedule has been created, it can be used by other users. The schedule is created with access to
PUBLIC
. Therefore, there is no need to explicitly grant access to the schedule.
repeat_interval:用法:
例如:設置任務僅在周5 的時候運行:
REPEAT_INTERVAL => 'FREQ=DAILY; BYDAY=FRI';
REPEAT_INTERVAL => 'FREQ=WEEKLY; BYDAY=FRI';
REPEAT_INTERVAL => 'FREQ=YEARLY; BYDAY=FRI';
上述三條語句雖然指定的關鍵字小有差異,不過功能相同。
設置任務隔一週運行一次,並且僅在周5 運行:
REPEAT_INTERVAL => 'FREQ=WEEKLY; INTERVAL=2; BYDAY=FRI';
設置任務在當月最後一天運行:
REPEAT_INTERVAL => 'FREQ=MONTHLY; BYMONTHDAY=-1';
設置任務在3 月10 日運行:
REPEAT_INTERVAL => 'FREQ=YEARLY; BYMONTH=MAR; BYMONTHDAY=10';
REPEAT_INTERVAL => 'FREQ=YEARLY; BYDATE=0310';
上述兩條語句功能相同。
設置任務每10 隔天運行:
REPEAT_INTERVAL => 'FREQ=DAILY; INTERVAL=10';
設置任務在每天的下午4、5、6 點時運行:
REPEAT_INTERVAL => 'FREQ=DAILY; BYHOUR=16,17,18';
設置任務在每月29 日運行:
REPEAT_INTERVAL => 'FREQ=MONTHLY; BYMONTHDAY=29';
設置任務在每年的最後一個周5 運行:
REPEAT_INTERVAL => 'FREQ=YEARLY; BYDAY=-1FRI';
設置任務每隔50 個小時運行:
REPEAT_INTERVAL => 'FREQ=HOURLY; INTERVAL=50';