1.获得当前自动收集统计信息的执行时间
col WINDOW_NAME for a20
col REPEAT_INTERVAL for a80
col DURATION for a30
set linesize 1200
SELECT t1.window_name, t1.repeat_interval, t1.duration,enabled FROM dba_scheduler_windows t1;
WINDOW_NAME REPEAT_INTERVAL DURATION ENABL
-------------------- -------------------------------------------------------------------------------- -----------------
MONDAY_WINDOW freq=daily;byday=MON;byhour=22;byminute=0; bysecond=0 +000 04:00:00 TRUE
TUESDAY_WINDOW freq=daily;byday=TUE;byhour=22;byminute=0; bysecond=0 +000 04:00:00 TRUE
WEDNESDAY_WINDOW freq=daily;byday=WED;byhour=22;byminute=0; bysecond=0 +000 04:00:00 TRUE
THURSDAY_WINDOW freq=daily;byday=THU;byhour=22;byminute=0; bysecond=0 +000 04:00:00 TRUE
FRIDAY_WINDOW freq=daily;byday=FRI;byhour=22;byminute=0; bysecond=0 +000 04:00:00 TRUE
SATURDAY_WINDOW freq=daily;byday=SAT;byhour=6;byminute=0; bysecond=0 +000 20:00:00 TRUE
SUNDAY_WINDOW freq=daily;byday=SUN;byhour=6;byminute=0; bysecond=0 +000 20:00:00 TRUE
WEEKNIGHT_WINDOW freq=daily;byday=MON,TUE,WED,THU,FRI;byhour=22;byminute=0; bysecond=0 +000 08:00:00 FALSE
WEEKEND_WINDOW freq=daily;byday=SAT;byhour=0;byminute=0;bysecond=0 +002 00:00:00 FALSE
2.修改自动收集统计信息的执行时间
2.1停止任务
SQL> BEGIN
DBMS_SCHEDULER.DISABLE(
name=>'"SYS"."MONDAY_WINDOW"',
force=>TRUE);
END;
/
BEGIN
DBMS_SCHEDULER.DISABLE(
name=>'"SYS"."TUESDAY_WINDOW"',
force=>TRUE);
END;
/
BEGIN
DBMS_SCHEDULER.DISABLE(
name=>'"SYS"."WEDNESDAY_WINDOW"',
force=>TRUE);
END;
/
BEGIN
DBMS_SCHEDULER.DISABLE(
name=>'"SYS"."THURSDAY_WINDOW"',
force=>TRUE);
END;
/
BEGIN
DBMS_SCHEDULER.DISABLE(
name=>'"SYS"."FRIDAY_WINDOW"',
force=>TRUE);
END;
/
BEGIN
DBMS_SCHEDULER.DISABLE(
name=>'"SYS"."SATURDAY_WINDOW"',
force=>TRUE);
END;
/
BEGIN
DBMS_SCHEDULER.DISABLE(
name=>'"SYS"."SUNDAY_WINDOW"',
force=>TRUE);
END;
/
SQL> 2 3 4 5 6
PL/SQL procedure successfully completed.
2.2 修改任务的持续时间,单位是分钟
SQL> BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."MONDAY_WINDOW"',
attribute=>'DURATION',
value=>numtodsinterval( 300, 'minute'));
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."TUESDAY_WINDOW"',
attribute=>'DURATION',
value=>numtodsinterval( 300, 'minute'));
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."WEDNESDAY_WINDOW"',
attribute=>'DURATION',
value=>numtodsinterval( 300, 'minute'));
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."THURSDAY_WINDOW"',
attribute=>'DURATION',
value=>numtodsinterval( 300, 'minute'));
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."FRIDAY_WINDOW"',
attribute=>'DURATION',
value=>numtodsinterval( 300, 'minute'));
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."SATURDAY_WINDOW"',
attribute=>'DURATION',
value=>numtodsinterval( 300, 'minute'));
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."SUNDAY_WINDOW"',
attribute=>'DURATION',
value=>numtodsinterval( 300, 'minute'));
END;
/
SQL> 2 3 4 5 6 7
PL/SQL procedure successfully completed.
2.3 开始执行时间,byhour=1,表示1点开始执行
SQL> BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."MONDAY_WINDOW"',
attribute=>'REPEAT_INTERVAL',
value=>'freq=daily;byday=MON;byhour=1;byminute=0; bysecond=0');
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."TUESDAY_WINDOW"',
attribute=>'REPEAT_INTERVAL',
value=>'freq=daily;byday=TUE;byhour=1;byminute=0; bysecond=0');
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."WEDNESDAY_WINDOW"',
attribute=>'REPEAT_INTERVAL',
value=>'freq=daily;byday=WED;byhour=1;byminute=0; bysecond=0');
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."THURSDAY_WINDOW"',
attribute=>'REPEAT_INTERVAL',
value=>'freq=daily;byday=THU;byhour=1;byminute=0; bysecond=0');
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."FRIDAY_WINDOW"',
attribute=>'REPEAT_INTERVAL',
value=>'freq=daily;byday=FRI;byhour=1;byminute=0; bysecond=0');
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."SATURDAY_WINDOW"',
attribute=>'REPEAT_INTERVAL',
value=>'freq=daily;byday=SAT;byhour=1;byminute=0; bysecond=0');
END;
/
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name=>'"SYS"."SUNDAY_WINDOW"',
attribute=>'REPEAT_INTERVAL',
value=>'freq=daily;byday=SUN;byhour=1;byminute=0; bysecond=0');
END;
/ 2 3 4 5 6 7
PL/SQL procedure successfully completed.
2.4开启任务
BEGIN
DBMS_SCHEDULER.ENABLE(
name=>'"SYS"."MONDAY_WINDOW"');
END;
/
BEGIN
DBMS_SCHEDULER.ENABLE(
name=>'"SYS"."TUESDAY_WINDOW"');
END;
/
BEGIN
DBMS_SCHEDULER.ENABLE(
name=>'"SYS"."WEDNESDAY_WINDOW"');
END;
/
BEGIN
DBMS_SCHEDULER.ENABLE(
name=>'"SYS"."THURSDAY_WINDOW"');
END;
/
BEGIN
DBMS_SCHEDULER.ENABLE(
name=>'"SYS"."FRIDAY_WINDOW"');
END;
/
BEGIN
DBMS_SCHEDULER.ENABLE(
name=>'"SYS"."SATURDAY_WINDOW"');
END;
/
BEGIN
DBMS_SCHEDULER.ENABLE(
name=>'"SYS"."SUNDAY_WINDOW"');
END;
/
2.5查看修改后自动收集统计信息的执行时间
col WINDOW_NAME for a20
col REPEAT_INTERVAL for a80
col DURATION for a30
set linesize 1200
SELECT t1.window_name, t1.repeat_interval, t1.duration,enabled FROM dba_scheduler_windows t1;SQL> SQL> SQL> SQL>
WINDOW_NAME REPEAT_INTERVAL DURATION ENABL
-------------------- -------------------------------------------------------------------------------- -----------------
MONDAY_WINDOW freq=daily;byday=MON;byhour=1;byminute=0; bysecond=0 +000 05:00:00 TRUE
TUESDAY_WINDOW freq=daily;byday=TUE;byhour=1;byminute=0; bysecond=0 +000 05:00:00 TRUE
WEDNESDAY_WINDOW freq=daily;byday=WED;byhour=1;byminute=0; bysecond=0 +000 05:00:00 TRUE
THURSDAY_WINDOW freq=daily;byday=THU;byhour=1;byminute=0; bysecond=0 +000 05:00:00 TRUE
FRIDAY_WINDOW freq=daily;byday=FRI;byhour=1;byminute=0; bysecond=0 +000 05:00:00 TRUE
SATURDAY_WINDOW freq=daily;byday=SAT;byhour=1;byminute=0; bysecond=0 +000 05:00:00 TRUE
SUNDAY_WINDOW freq=daily;byday=SUN;byhour=1;byminute=0; bysecond=0 +000 05:00:00 TRUE
WEEKNIGHT_WINDOW freq=daily;byday=MON,TUE,WED,THU,FRI;byhour=22;byminute=0; bysecond=0 +000 08:00:00 FALSE
WEEKEND_WINDOW freq=daily;byday=SAT;byhour=0;byminute=0;bysecond=0 +002 00:00:00 FALSE
9 rows selected.