Oracle® Database Administrator's Guide 11g Release 2 (11.2) Part Number E17120-07 |
|
|
PDF · Mobi · ePub |
You may want to adjust the predefined maintenance windows to a time suitable to your database environment or create a new maintenance window. You can customize maintenance windows using the DBMS_SCHEDULER
PL/SQL package.
This section contains the following topics:
The DBMS_SCHEDULER
PL/SQL package includes a SET_ATTRIBUTE
procedure for modifying the attributes of a window. For example, the following script changes the duration of the maintenance window SATURDAY_WINDOW
to 4 hours:
BEGIN dbms_scheduler.disable( name => 'SATURDAY_WINDOW'); dbms_scheduler.set_attribute( name => 'SATURDAY_WINDOW', attribute => 'DURATION', value => numtodsinterval(4, 'hour')); dbms_scheduler.enable( name => 'SATURDAY_WINDOW'); END; /
Note that you must use the DBMS_SCHEDULER.DISABLE
subprogram to disable the window before making changes to it, and then re-enable the window with DBMS_SCHEDULER.ENABLE
when you are finished. If you change a window when it is currently open, the change does not take effect until the next time the window opens.
See Also:
"Managing Job Scheduling and Job Priorities with Windows" for more information about modifying windows.To create a new maintenance window, you must create an Oracle Scheduler window object and then add it to the window group MAINTENANCE_WINDOW_GROUP
. You use the DBMS_SCHEDULER
.CREATE_WINDOW
package procedure to create the window, and the DBMS_SCHEDULER
.ADD_GROUP_MEMBER
procedure to add the new window to the window group.
The following example creates a maintenance window named EARLY_MORNING_WINDOW
. This window runs for one hour daily between 5 a.m. and 6 a.m.
BEGIN dbms_scheduler.create_window( window_name => 'EARLY_MORNING_WINDOW', duration => numtodsinterval(1, 'hour'), resource_plan => 'DEFAULT_MAINTENANCE_PLAN', repeat_interval => 'FREQ=DAILY;BYHOUR=5;BYMINUTE=0;BYSECOND=0'); dbms_scheduler.add_group_member( group_name => 'MAINTENANCE_WINDOW_GROUP', member => 'EARLY_MORNING_WINDOW'); END; /
See Also:
Oracle Database PL/SQL Packages and Types Reference for information on the DBMS_SCHEDULER
package
To remove an existing maintenance window, remove it from the MAINTENANCE_WINDOW_GROUP
window group. The window continues to exist but no longer runs automated maintenance tasks. Any other Oracle Scheduler jobs assigned to this window continue to run as usual.
The following example removes EARLY_MORNING_WINDOW
from the window group:
BEGIN DBMS_SCHEDULER.REMOVE_GROUP_MEMBER( group_name => 'MAINTENANCE_WINDOW_GROUP', member => 'EARLY_MORNING_WINDOW'); END; /
See Also:
Oracle Database PL/SQL Packages and Types Reference for information on the DBMS_SCHEDULER
package