JOB_ACTION => 'insert into emp select * from scott.emp where empno=7396',
REPEAT_INTERVAL => 'freq=monthly;bymonth=3,6,9,12',
ENABLED => TRUE);
END;
/
从上面的查询可以看出,下次job执行的时间是17年6月15日,因为现在是5月,所以job并没有执行。
4、byweekno_clause
byweekno_clause = "BYWEEKNO" "=" weeknumber_list weeknumber_list = weeknumber ( "," weeknumber)* weeknumber = [minus] weekno weekno = 1 through 53该参数用于指定在一年中的第几周执行job��每年有52或53周,该参数只针对FREQ=YEARLY有效。
5、byyearday_clause
byyearday_clause = "BYYEARDAY" "=" yearday_list yearday_list = yearday ( "," yearday)* yearday = [minus] yeardaynum yeardaynum = 1 through 366该参数指定一年中的第几天执行job,有效值为1-366,也可以在数字前指定"-"代表该年的倒数第几天如"-2"表示12月30日。
示例:指定每年的倒数第二天执行job
BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB(JOB_NAME => 'tst1',
JOB_TYPE => 'plsql_block',
JOB_ACTION => 'insert into emp select * from scott.emp where empno=7396',
REPEAT_INTERVAL => 'freq=yearly;byyearday=-2',
ENABLED => TRUE);
END;
/
从上图可以看出,job的执行时间为17年12月30日,即17年的倒数第二天。
6、bydate_clause
语法如下:
bydate_clause = "BYDATE" "=" date_list date_list = date ( "," date)* date = [YYYY]MMDD [ offset | span ]该参数用于指定哪一天执行job,格式为[YYYY]MMDD。可以用span参数指定连续的日期如bydate=0110,0111,0112,0113,0114与bydate=0110+span:5d等价。可以用offset参数对日期做调整,增加/减少几天(d)或几周(w)如bydate=0520-offset:5d,表示指定5月15日执行。
7、byday_clause
语法如下:
byday_clause = "BYDAY" "=" byday_list byday_list = byday ( "," byday)* byday = [weekdaynum] day weekdaynum = [minus] daynum daynum = 1 through 53 /* if frequency is yearly */ daynum = 1 through 5 /* if frequency is monthly */ day = "MON" | "TUE" | "WED" | "THU" | "FRI" | "SAT" | "SUN"指定一周中的周几执行job,使用单词的前三个字母指定。如果指定的freq=yearly,则daynum可以是1-53,指定一年的第几周。如果freq=monthly,则daynum可以是1-5,指定一个月的第几周。使用"-"表示倒数。
示例:每个月第3周的周五执行job
BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB(JOB_NAME => 'tst1',
JOB_TYPE => 'plsql_block',