Monitor and Administer Database
Monitor and Administer Database
OS=DBA
Learning module:09
Unit of competence: Monitor and Administer Database
Module Title: Monitoring and Administering Database
Occupational code: ICT DBA4 09 0710
LO1: Start up a database
LO2: Manage database
LO3: Manage database access
Trainees manual and information sheet for DBA level
IV
Compiled By D
in 12/12/2007
1
Technical Note
Administering the Monitoring
database
Administering the Monitoring database
Introduction to Database Management
Database management involves the monitoring, administration, and maintenance of the databases and
database groups in your enterprise. Enterprise Manager is the premier tool for managing your database
environment.
Enterprise Manager provides two separate consoles that you can use to monitor your database:
Database Control and Grid Control.
Database Control is the Enterprise Manager Web-based application for managing Oracle
Database 10g Release 2 (10.2). Database Control is installed and available with every Oracle
Database 10g installation. From Database Control, you can monitor and administer a single
Oracle Database instance or a clustered database.
Grid Control is the Enterprise Manager console you use to centrally manage your entire Oracle
environment. Within Grid Control, you access the multiple database targets using the Targets
tab, then Databases.
The Enterprise Manager Database Home page shows important status and performance information
about your database instance from a single source, including:
A quick view of the status of the database and basic information about the database
Relative CPU utilization of the Oracle host
Amount of time the instance consumed using CPU and I/O, and the amount of time it
consumed in bottlenecks
Current response of the tracked set of SQL versus the reference collection response
2
The number of Automatic Database Diagnostic Monitoring (ADDM) findings, the number of
policy violations (Database Control only), and the Alert Log status
Storage-related issues and recommendations for improved performance, and information about
space violations and ADDM
The most recent backup time and backup status
Outstanding alerts and related alerts
Rolled-up number of Oracle policy violations across all member targets in a system
A quick view of database security
Job executions that show the scheduled, running, suspended, and problem executions
Starting from the Database Home page, you can access additional details and management functions
by drilling down through the user interface. In addition, the Database Home page provides a list of
Related Links. From these links you can perform activities such as editing metric thresholds, analyzing
job activity and metric collection errors, and accessing a number of advisors to help you improve the
performance of your database.
Monitoring Databases
Comprehensive database monitoring enables you to identify the problem areas in your database
environment that are degrading performance. After you have identified the areas to improve, you can
tune your databases' performance using the Enterprise Manager administration capabilities.
Enterprise Manager uses data from the Automatic Workload Repository (AWR) to display
performance information and initiate database alerts. The user interface provides several real-time
performance charts and drill-downs for the targets you manage. Both aggregate and instance-specific
performance statistics are displayed using color-coded charts for easier viewing. To help you identify
the source of a problem and resolve it, you can click a legend link next to a chart to display a detail
page that provides comprehensive information.
The basic work flow in monitoring performance is to first go to the Database Performance page, which
provides a high-level, comprehensive overview of important performance indicators.
Database tuning is much easier and more effective when all the information for an in-depth
performance diagnosis is available on a single screen. On the Database Performance page (which is
accessible from the Database Home page, you can quickly view performance data for the instance and
its underlying host. Additionally, you can analyze trends for all critical performance metrics and
compare the trends to those of other database instances.
The most direct method for investigating and diagnosing performance problems from this page
consists of accessing the Automatic Database Diagnostic Monitor (ADDM). After you start your
Oracle database, the Automatic Workload Repository (AWR) begins taking snapshots of database
activity once every hour by default, and ADDM executes when the snapshots are collected. ADDM
uses these snapshots to perform a top-down analysis of your database activity and then provide tuning
recommendations.
3
Another method for investigating and diagnosing performance problems consists of observing which
of the wait classes beside the Average Active Sessions chart appears to be consuming an excessive
amount of time, shown as a spike above the Maximum CPU line, then drilling down for more
information. This provides a way for you to visualize the data for which ADDM has made its
recommendations.
Either method assists you in diagnosing and resolving problems. The first automated method produces
textual findings, whereas the second interactive method produces graphical findings.
This section contains the following topics relating to starting up an instance of a database:
You can start a SQL*Plus session, connect to Oracle Database with administrator privileges, and then
issue the STARTUP command. Using SQL*Plus in this way is the only method described in detail in
this book.
You can also use Recovery Manager (RMAN) to execute STARTUP and SHUTDOWN commands. You
may prefer to do this if your are within the RMAN environment and do not want to invoke SQL*Plus.
See Also:
Oracle Database Backup and Recovery User's Guide for information on starting up the database using
RMAN
You can use Oracle Enterprise Manager (EM) to administer your database, including starting it up and
shutting it down. EM combines a GUI console, agents, common services, and tools to provide an
integrated and comprehensive systems management platform for managing Oracle products. EM
Database Control, which is the portion of EM that is dedicated to administering an Oracle database,
enables you to perform the functions discussed in this book using a GUI interface, rather than
command line operations.
See Also:
4
The remainder of this section describes using SQL*Plus to start up a database instance.
When you issue the SQL*Plus STARTUP command, the database attempts to read the initialization
parameters from an SPFILE in a platform-specific default location. If it finds no SPFILE, it searches for
a text initialization parameter file.
Note:
For UNIX or Linux, the platform-specific default location (directory) for the SPFILE and text
initialization parameter file is:
$ORACLE_HOME/dbs
%ORACLE_HOME%\database
In the platform-specific default location, Oracle Database locates your initialization parameter file by
examining filenames in the following order:
1. spfile$ORACLE_SID.ora
2. spfile.ora
3. init$ORACLE_SID.ora
The first two filenames represent SPFILEs and the third represents a text initialization parameter file.
Note:
The spfile.ora file is included in this search path because in an Oracle Real Application Clusters
environment one server parameter file is used to store the initialization parameter settings for all
instances. There is no instance-specific location for storing a server parameter file.
For more information about the server parameter file for an Oracle Real Application Clusters
environment, see Oracle Real Application Clusters Administration and Deployment Guide.
If you (or the Database Configuration Assistant) created a server parameter file, but you want to
override it with a text initialization parameter file, you can specify the PFILE clause of the STARTUP
command to identify the initialization parameter file.
5
A non-default server parameter file (SPFILE) is an SPFILE that is in a location other than the default
location. It is not usually necessary to start an instance with a non-default SPFILE. However, should
such a need arise, you can use the PFILE clause to start an instance with a non-default server parameter
file as follows:
1. Create a one-line text initialization parameter file that contains only the SPFILE parameter. The
value of the parameter is the non-default server parameter file location.
SPFILE = /u01/oracle/dbs/test_spfile.ora
Note:
You cannot use the IFILE initialization parameter within a text initialization parameter file to
point to a server parameter file. In this context, you must use the SPFILE initialization
parameter.
The SPFILE must reside on the machine running the database server. Therefore, the preceding method
also provides a means for a client machine to start a database that uses an SPFILE. It also eliminates
the need for a client machine to maintain a client-side initialization parameter file. When the client
machine reads the initialization parameter file containing the SPFILE parameter, it passes the value to
the server where the specified SPFILE is read.
Note that on the UNIX and Linux platforms, if your SPFILE is not in the default location, you can also
create a symbolic link to the SPFILE and place the symbolic link in the default location.
See Table 2-3 for information on PFILE and SPFILE default names and locations.
A database that uses Automatic Storage Management (ASM) usually has a non-default SPFILE. If you
use the Database Configuration Assistant (DBCA) to configure a database to use ASM, DBCA creates
an SPFILE for the database instance in an ASM disk group, and then creates a text initialization
parameter file in the default location in the local file system to point to the SPFILE.
See Also:
Chapter 2, "Creating and Configuring an Oracle Database", for more information about initialization
parameters, initialization parameter files, and server parameter files
6
You must perform some preliminary steps before attempting to start an instance of your database using
SQL*Plus.
1. Ensure that environment variables are set so that you connect to the desired Oracle instance.
For details, see
Now you are connected to the database and ready to start up an instance of your database.
See Also:
SQL*Plus User's Guide and Reference for descriptions and syntax for the CONNECT, STARTUP, and
SHUTDOWN commands.
Starting Up an Instance
You use the SQL*Plus STARTUP command to start up an Oracle Database instance. You can start an
instance in various modes:
Start the instance without mounting a database. This does not allow access to the database and
usually would be done only for database creation or the re-creation of control files.
Start the instance and mount the database, but leave it closed. This state allows for certain
DBA activities, but does not allow general access to the database.
Start the instance, and mount and open the database. This can be done in unrestricted mode,
allowing access to all users, or in restricted mode, allowing access for database administrators
only.
Force the instance to start after a startup or shutdown problem, or start the instance and have
complete media recovery begin immediately.
Note:
You cannot start a database instance if you are connected to the database through a shared server
process.
The following scenarios describe and illustrate the various states in which you can start up an instance.
Some restrictions apply when combining clauses of the STARTUP command.
Note:
7
It is possible to encounter problems starting up an instance if control files, database files, or redo log
files are not available. If one or more of the files specified by the CONTROL_FILES initialization
parameter does not exist or cannot be opened when you attempt to mount a database, Oracle Database
returns a warning message and does not mount the database. If one or more of the datafiles or redo log
files is not available or cannot be opened when attempting to open a database, the database returns a
warning message and does not open the database.
See Also:
SQL*Plus User's Guide and Reference for information about the restrictions that apply when
combining clauses of the STARTUP command
Normal database operation means that an instance is started and the database is mounted and open.
This mode allows any valid user to connect to the database and perform data access operations.
The following command starts an instance, reads the initialization parameters from the default
location, and then mounts and opens the database. (You can optionally specify a PFILE clause.)
STARTUP
You can start an instance without mounting a database. Typically, you do so only during database
creation. Use the STARTUP command with the NOMOUNT clause:
STARTUP NOMOUNT
You can start an instance and mount a database without opening it, allowing you to perform specific
maintenance operations. For example, the database must be mounted but not open during the
following tasks:
Enabling and disabling redo log archiving options. For more information, please refer to
Chapter 11, "Managing Archived Redo Logs".
Performing full database recovery. For more information, please refer to Oracle Database
Backup and Recovery User's Guide
The following command starts an instance and mounts the database, but leaves the database closed:
STARTUP MOUNT
You can start an instance, and optionally mount and open a database, in restricted mode so that the
instance is available only to administrative personnel (not general database users). Use this mode of
instance startup when you need to accomplish one of the following tasks:
8
Perform an export or import of data
Perform a data load (with SQL*Loader)
Temporarily prevent typical users from using data
Perform certain migration or upgrade operations
Typically, all users with the CREATE SESSION system privilege can connect to an open database.
Opening a database in restricted mode allows database access only to users with both the CREATE
SESSION and RESTRICTED SESSION system privilege. Only database administrators should have the
RESTRICTED SESSION system privilege. Further, when the instance is in restricted mode, a database
administrator cannot access the instance remotely through an Oracle Net listener, but can only access
the instance locally from the machine that the instance is running on.
The following command starts an instance (and mounts and opens the database) in restricted mode:
STARTUP RESTRICT
You can use the RESTRICT clause in combination with the MOUNT, NOMOUNT, and OPEN clauses.
Later, use the ALTER SYSTEM statement to disable the RESTRICTED SESSION feature:
If you open the database in nonrestricted mode and later find that you need to restrict access, you can
use the ALTER SYSTEM statement to do so, as described in "Restricting Access to an Open Database".
See Also:
Oracle Database SQL Language Reference for more information on the ALTER SYSTEM statement
In unusual circumstances, you might experience problems when attempting to start a database
instance. You should not force a database to start unless you are faced with the following:
You cannot shut down the current instance with the SHUTDOWN NORMAL, SHUTDOWN IMMEDIATE,
or SHUTDOWN TRANSACTIONAL commands.
If one of these situations arises, you can usually solve the problem by starting a new instance (and
optionally mounting and opening the database) using the STARTUP command with the FORCE clause:
STARTUP FORCE
If an instance is running, STARTUP FORCE shuts it down with mode ABORT before restarting it. In this
case, beginning with Oracle Database 10g Release 2, the alert log shows the message "Shutting down
instance (abort)" followed by "Starting ORACLE instance (normal)." (Earlier versions of the
database showed only "Starting ORACLE instance (force)" in the alert log.)
9
See Also:
"Shutting Down with the ABORT Clause" to understand the side effects of aborting the current
instance
If you know that media recovery is required, you can start an instance, mount a database to the
instance, and have the recovery process automatically start by using the STARTUP command with the
RECOVER clause:
If you attempt to perform recovery when no recovery is required, Oracle Database issues an error
message.
Many sites use procedures to enable automatic startup of one or more Oracle Database instances and
databases immediately following a system start. The procedures for performing this task are specific to
each operating system. For information about automatic startup, see your operating system specific
Oracle documentation.
If your local Oracle Database server is part of a distributed database, you might want to start a remote
instance and database. Procedures for starting and stopping remote instances vary widely depending
on communication protocol and operating system.
Lo2:mange database
Library Example
Let's consider an example of how databases are used. Think of a public library. A library contains
books, magazines, CDs, DVDs and other materials. All these materials need to be catalogued so we
know what is available in the library. For each item, the catalog would describe things like the type of
item, the title, the authors, the publishers and other relevant details. The catalog also needs to be
10
searchable, so the librarian typically assigns some keywords to each item. The library catalog is a type
of database.
Once we have a catalog, we also need to have a way for users to check out the materials. Users need to
be able to register, get a library card and use this card to check out the materials they want to take
home. So the library needs a database of users. This would include the user's name, address, telephone
number, e-mail and age. With a catalog of materials and a user database, the library can start
operating. What is needed to support the day-to-day operations is a system to keep track of which
materials each user checks out and when they get returned. This system needs to be linked to the
catalog and the user database.
Now consider how you actually use the library and what decisions are being made. You go to the
library and want to learn something about the theory of evolution. The first thing you probably do is
go to a computer terminal and search the catalog with a keyword like 'evolution theory.' You browse
through the results to see which books might be most useful. Once you have found a few titles, you
can check to make sure they are not already checked out.
You find the materials you are interested in on the shelves and take them to the checkout counter. The
staff at the counter scans your library card to make sure your account is in good standing. If you have
books overdue, the staff member will be quick to remind you. Then the materials you want to check
out are scanned, and the staff member will make sure you don't exceed any limits set by the library -
such as a maximum of three music CDs.
You take your materials home, and a week later you get a reminder e-mail that your music CDs are
due, since you can only keep them for a week. You return the music CDs but keep the books for now.
Two weeks later, you get a reminder your books are due. You are not quite done reading them, so you
log on to the library's website and renew the books online. A few weeks later, you return the books.
Throughout these steps, you have used the library system in several ways:
All of this is possible because of the database systems maintained by the library.
Also consider how the library staff uses the databases. Staff at the checkout counters process user
requests. Librarians add new books to the catalogue and help users find materials at other libraries.
Senior staff at the library analyze how the collections are being used, which new materials should be
acquired and how to best meet the needs of the many library users. All of these decisions are informed
by the various databases.
To unlock this lesson you must be a Study.com Member. Create your account
11
Lo3: Manage database access
Each Access database consists of multiple objects that let you interact with data. Databases can
include forms for entering data, queries for searching within it, reports for analyzing it, and tables
for storing it. Whenever you work with your database, you are working with many of these objects at
once. Fortunately, Access makes managing these objects pretty easy.
In this lesson, you will learn how to to open and close databases, as well as how to open, close, and
save objects.
Throughout this tutorial, we will be using a sample database. If you would like to follow along,
download our example and use it to follow the procedures demonstrated in this lesson.
In Access 2010, database objects are displayed in the Navigation Pane, a feature introduced in Access
2007. The Database window of earlier versions is not available.
You can customize the categories and groups of objects in the Navigation Pane. You can also hide
objects, groups, or even the entire Navigation Pane. Access 2010 provides several categories that you
can use right away, and also lets you create custom categories and groups.
Note The Navigation Pane is not available when you use a Web database in a browser. However, you
can use the Navigation Pane when you open a Web database by using Access.
The Navigation Pane is the primary means by which you view and access all your database objects.
When you open a database in Access 2010, by default the Navigation Pane appears along the left side
of the workspace.
You can adjust the appearance of the Navigation Pane in the following ways:
To Do this
Position the pointer over the right edge of the Navigation Pane and then, when
Change the width of the
it changes to a double-sided arrow, drag the edge to increase or decrease the
Navigation Pane
width.
Open and close the Click the Shutter Bar Open/Close Button , or press F11 to open and
Navigation Pane close the Navigation Pane.
12
Using database objects
You can use any object in the Navigation Pane by double-clicking it. If you right-click an object, you
see a shortcut menu that lets you do a variety of things, such as opening an object in Design view.
You can organize the objects in a database into categories and groups. Categories let you arrange the
objects in the Navigation Pane and groups let you filter the categorized objects.
13
For example, in the preceding figure, Object Type is the category, and All Access Objects is the
group.
When you select a category, the items are arranged into the groups that the category contains. For
example, if you choose the Tables and Related Views category, the items are arranged into one group
per table, with each group containing shortcuts to all the objects that use the table — queries, forms,
reports, and so on. If an object uses more than one table, it appears in all relevant groups.
Top of Page
Select a category
When you create a new database, the category displayed by default is Tables and Related Views, and
the group is All Tables. Every database also has a category named Custom that you can use to create
a custom view of your objects. In addition, Access provides two more predefined categories that you
can select, according to the way in which you want the objects to be displayed:
Category Description
Object
View all the objects in the database, sorted by their type.
Type
Created
Date
Locate objects that are created or modified on a specific date or in a date range. You can
and filter by Today or All Dates. These categories display objects in descending order from
when they were created or last modified.
Modified
Date
14
For example, in the Northwind sample database, if you display the All Tables group, you see this:
Note the Employees group displays the Employees table followed by the objects related to the
Employees table. If you expand their groups, the same occurs with the remaining tables.
15
Each time that you select a predefined category, Access
includes a global group that contains all the objects in the database. You can easily locate the global
group for a category by looking for the word All in front of the group name. For example, if you select
the Tables and Related Views category, the global group is called All Tables.
Top of Page
Right-click the top of the Navigation Pane to display the shortcut menu, and then do any one of
the following:
o To change how the objects are displayed, point to View By, and then click either
Details, Icon, or List.
o To view all the groups in the database, click Show all groups.
o To change the sort order of the Navigation Pane, point to Sort By and then select a
sorting option.
o To sort manually and customize the display order, click Sort By, and then click
Remove Automatic Sorts.
Top of Page
16
Find objects in a database
While you type text in the Search box, Access searches within the category for any groups that
contain an object or object shortcut that meets your search terms. Any groups that don't contain a
match are collapsed.
Note Access searches for objects only in the categories and groups that are currently displayed in the
Navigation Pane.
Tip To search the whole database for a specific object, select one of the predefined categories in the
Navigation Pane, such as Tables and Related Views or Object Type. This helps make sure that all
the groups are visible in the Navigation Pane.
1. If the Search box is not already visible at the top of the Navigation Pane, right-click the menu
bar at the top of the Navigation Pane, and then click Search Bar.
2. Type either a part or the complete name of the object or shortcut in the Search Bar box.
3. To perform another search, click Clear Search String or press BACKSPACE to delete
characters, and then type the new text for which you want to search.
Note When you clear the Search Bar box, the Navigation Pane again displays all of the
available objects.
Top of Page
When you view custom categories and groups from the Navigation Pane, you always see the shortcuts
to the objects. Shortcuts can be identified by a small arrow next to the lower-left corner of the object
icon.
17
When you open a shortcut, you open the object it points to. However,
if you delete a shortcut, Office Access 2007 does not delete the object in the database that the shortcut
points to. You can also hide and rename shortcuts without changing the data that the shortcuts point to
in the database.
One way to customize the objects in a database is by creating custom categories. For example, you can
create a custom category when you want to create a form with specific types of buttons or links that
you can use to navigate the database. When you create a custom category, it applies to the current
database only. You cannot transfer custom categories and groups to other databases. You can create a
custom category by either renaming the default Custom category that Access provides or by creating a
new custom category. Limiting the number of custom categories and groups in your database can
make it easier to locate data.
Note Although you can remove objects from a custom category or group, you cannot remove objects
from a predefined category or group.
Use the Navigation Options dialog box to create and manage custom categories and groups. The
dialog box displays a list of all the categories that have been defined in the database, and shows the
groups for a selected category.
When you create a new custom category, groups named Unassigned Objects and Custom Group 1
are created for that category. By default, Office Access 2007 does not put any objects in the
Unassigned Objects group. Instead, all the objects in a category that are not assigned to any group are
displayed in the Unassigned Objects group in the Navigation Pane.
1. To create a new category, right-click the menu at the top of the Navigation Pane, and then click
Navigation Options.
A new category appears under Categories in the Navigation Options dialog box.
3. Type a name for the new category, and then press ENTER.
If an unused custom category is available, you can rename it instead of adding a new custom category.
1. To rename a custom category, right-click the menu at the top of the Navigation Pane, and then
click Navigation Options.
18
2. Under Categories, click Custom, and then click Rename Item.
3. Type a new name for the category, and then press ENTER.
After you create or rename a custom category, you need to create custom groups under each custom
category.
Access automatically creates a Custom Group 1 and an Unassigned Objects group under each new
category. Objects that are not assigned to groups are automatically put in the Unassigned Objects
group. You can either create a new custom group or rename the Custom Group 1 group to the name
that you choose.
1. To create a new custom group, right-click the menu at the top of the Navigation Pane, and then
click Navigation Options.
3. Type a name for the new group, and then press ENTER.
1. To rename a custom group, right-click the menu at the top of the Navigation Pane, and then
click Navigation Options.
2. Under Groups for category name, click the custom group, and then click Rename Group.
3. Type a new name for the group, and then press ENTER.
After you have created a custom group in a custom category, you add or move objects, such as tables,
into the custom group.
To add or move objects in the database into a custom group, click the drop-down arrow at the
top of the Navigation Pane, and then click the custom group that you created.
Under Unassigned Objects, right-click the object that you want to add or move.
Click Add to group on the shortcut menu, and then click the custom group that you want to
add the object to.
19
Copy and paste objects
In the Navigation Pane, right-click the object that you want to copy, and then click Copy.
Right-click the group in the Navigation Pane where you want to paste the object, and then click
Paste. You can also paste the object into the Navigation Pane of another database that is open
in Access 2010.
Importing tables from other databases or data from other programs (such as text files and Microsoft
Office Excel workbooks) is another way to add objects to your database. For more information about
how to import external data, see the links in the See Also section of this article.
Top of Page
If you remove or delete a shortcut from the Navigation Pane, you are
only removing the pointer to that object and not removing the object from the database. When the
shortcut of an object is removed from a custom group in the Navigation Pane, the reference to the
object is removed from the custom group, and the object appears in the Unassigned Objects group in
the Navigation Pane.
To remove a shortcut, right-click the object in the Navigation Pane, and then click Remove.
To restore the shortcut for the object, drag the object from the Unassigned Objects group in
the Navigation Pane to the custom group.
Important Although you can delete (that is, permanently remove) predefined and custom groups, we
do not recommend doing this because it can cause problems in the database. Databases are sets of
components that work together, and if an object is deleted from that set of components, it can break
part or all the functionality of the database.
20
To hide an object or group in the Navigation Pane, do one of the following:
To hide an object, right-click the object, and then click Hide in this Group.
To hide an entire group, right-click the group, and then click Hide.
To hide an object or group that appears dimmed in the Navigation Pane, do the following:
1. Right-click the menu bar at the top of the Navigation Pane, and then click Navigation
Options.
2. In the Navigation Options dialog box, clear the Show Hidden Objects check box, and then
click OK.
Right-click the menu bar at the top of the Navigation Pane, and then click Navigation
Options.
In the Navigation Options dialog box, select the Show Hidden Objects check box, and then
click OK.
If the hidden objects and groups appear dimmed in the Navigation Pane, they are not enabled. To
make these dimmed objects or groups available from the Navigation Pane, do the following:
To enable an object, right-click the object, and then click Unhide in this Group.
Oracle Database has automated several common maintenance tasks typically performed by database
administrators. These automated maintenance tasks are performed when the system load is expected to
be light. You can enable and disable individual maintenance tasks, and can configure when these tasks
run and what resource allocations they are allotted.
In this chapter:
21
Configuring Resource Allocations for Automated Maintenance Tasks
Automated Maintenance Tasks Reference
Note:
This chapter explains how to administer automated maintenance tasks using PL/SQL packages. An
easier way is to use the graphical interface of Enterprise Manager.
See Oracle Database 2 Day DBA or the Oracle Enterprise Manager Grid Control online help
for instructions.
2. On the Database Home Page, click Server to display the Server page.
3. Under the Oracle Scheduler section, click Automated Maintenance Tasks to configure
maintenance tasks, or Windows to configure maintenance windows.
Automatic Optimizer Statistics Collection—Collects optimizer statistics for all schema objects
in the database for which there are no statistics or only stale statistics. The statistics gathered
by this task are used by the SQL query optimizer to improve the performance of SQL
execution.
See Also:
Oracle Database Performance Tuning Guide for more information on automatic statistics
collection
Automatic Segment Advisor—Identifies segments that have space available for reclamation,
and makes recommendations on how to defragment those segments.
You can also run the Segment Advisor manually to obtain more up-to-the-minute
recommendations or to obtain recommendations on segments that the Automatic Segment
Advisor did not examine for possible space reclamation.
22
See Also:
See Also:
Oracle Database Performance Tuning Guide for more information on SQL Tuning Advisor
By default, all three automated maintenance tasks are configured to run in all maintenance windows.
When a maintenance window opens, Oracle Database creates an Oracle Scheduler job for each
maintenance task that is scheduled to run in that window. Each job is assigned a job name that is
generated at run time. All automated maintenance task job names begin with ORA$AT. For example, the
job for the Automatic Segment Advisor might be called ORA$AT_SA_SPC_SY_26. When an automated
maintenance task job finishes, it is deleted from the Oracle Scheduler job system. However, the job
can still be found in the Scheduler job history.
Note:
In the case of a very long maintenance window, all automated maintenance tasks except Automatic
SQL Tuning Advisor are restarted every four hours. This feature ensures that maintenance tasks are
run regularly, regardless of window size.
The framework of automated maintenance tasks relies on maintenance windows being defined in the
database. Table 26-1 lists the maintenance windows that are automatically defined with each new
Oracle Database installation.
See Also:
"About Jobs and Supporting Scheduler Objects" for more information on windows and groups.
23
To enable or disable specific maintenance tasks in any subset of maintenance windows, you can use
the DBMS_AUTO_TASK_ADMIN PL/SQL package.
You can disable a particular automated maintenance task for all maintenance windows with a single
operation. You do so by calling the DISABLE procedure of the DBMS_AUTO_TASK_ADMIN PL/SQL
package without supplying the window_name argument. For example, you can completely disable the
Automatic SQL Tuning Advisor task as follows:
BEGIN
dbms_auto_task_admin.disable(
client_name => 'sql tuning advisor',
operation => NULL,
window_name => NULL);
END;
/
To enable this maintenance task again, use the ENABLE procedure, as follows:
BEGIN
dbms_auto_task_admin.enable(
client_name => 'sql tuning advisor',
operation => NULL,
window_name => NULL);
END;
/
The task names to use for the client_name argument are listed in the DBA_AUTOTASK_CLIENT
database dictionary view.
To enable or disable all automated maintenance tasks for all windows, call the ENABLE or DISABLE
procedure with no arguments.
EXECUTE DBMS_AUTO_TASK_ADMIN.DISABLE;
See Also:
Oracle Database PL/SQL Packages and Types Reference for more information on the
DBMS_AUTO_TASK_ADMIN PL/SQL package.
24
Enabling and Disabling Maintenance Tasks for Specific Maintenance Windows
By default, all maintenance tasks run in all predefined maintenance windows. You can disable a
maintenance task for a specific window. The following example disables the Automatic SQL Tuning
Advisor from running in the window MONDAY_WINDOW:
BEGIN
dbms_auto_task_admin.disable(
client_name => 'sql tuning advisor',
operation => NULL,
window_name => 'MONDAY_WINDOW');
END;
/
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:
25
"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:
"Creating Windows"
Oracle Database PL/SQL Packages and Types Reference for information on the
DBMS_SCHEDULER package
BEGIN
DBMS_SCHEDULER.REMOVE_GROUP_MEMBER(
group_name => 'MAINTENANCE_WINDOW_GROUP',
member => 'EARLY_MORNING_WINDOW');
END;
/
See Also:
26
Oracle Database PL/SQL Packages and Types Reference for information on the
DBMS_SCHEDULER package
See Also:
By default, all predefined maintenance windows use the resource plan DEFAULT_MAINTENANCE_PLAN.
Automated maintenance tasks run under its subplan ORA$AUTOTASK_SUB_PLAN. This subplan divides
its portion of total resource allocation equally among the maintenance tasks.
In this plan, any sessions in the SYS_GROUP consumer group get priority. (Sessions in this group are
sessions created by user accounts SYS and SYSTEM.) Any resource allocation that is unused by sessions
in SYS_GROUP is then shared by sessions belonging to the other consumer groups and subplans in the
plan. Of that allocation, 25% goes to maintenance tasks, 5% goes to background processes performing
diagnostic operations, and 70% goes to user sessions. The maximum utilization limit for
ORA$AUTOTASK_SUB_PLAN and ORA$DIAGNOSTICS is 90. Therefore, even if the CPU is idle, this
group/plan cannot be allocated more than 90% of the CPU resources.
To reduce or increase resource allocation to the automated maintenance tasks, you make adjustments
to DEFAULT_MAINTENANCE_PLAN. See "Changing Resource Allocations for Automated Maintenance
Tasks" for more information.
Note that as with any resource plan, the portion of an allocation that is not used by a consumer group
or subplan is available for other consumer groups or subplans. Note also that the Database Resource
Manager does not begin to limit resource allocations according to resource plans until 100% of CPU is
being used.
27
Note:
Although DEFAULT_MAINTENANCE_PLAN is the default, you can assign any resource plan to any
maintenance window. If you do change a maintenance window resource plan, ensure that you include
the subplan ORA$AUTOTASK_SUB_PLAN and the consumer group ORA$DIAGNOSTICS in the new plan.
See Also:
Chapter 27, "Managing Resources with Oracle Database Resource Manager" for more information on
resource plans.
To change the resource allocation for automated maintenance tasks within a maintenance window, you
must change the percentage of resources allocated to the subplan ORA$AUTOTASK_SUB_PLAN in the
resource plan for that window. (By default, the resource plan for each predefined maintenance window
is DEFAULT_MAINTENANCE_PLAN.) You must also adjust the resource allocation for one or more other
subplans or consumer groups in the window's resource plan such that the resource allocation at the top
level of the plan adds up to 100%. For information on changing resource allocations, see Chapter 27,
"Managing Resources with Oracle Database Resource Manager".
By default there are seven predefined maintenance windows, each one representing a day of the week.
The weekend maintenance windows, SATURDAY_WINDOW and SUNDAY_WINDOW, are longer in duration
than the weekday maintenance windows. The window group MAINTENANCE_WINDOW_GROUP consists of
these seven windows. The list of predefined maintenance windows is given in Table 26-1.
28
Automated Maintenance Tasks Database Dictionary Views
Table 26-2 displays information about database dictionary views for automated maintenance tasks:
29