1Z0-042_StudyGuide(2)
Short Description
Download 1Z0-042_StudyGuide(2)...
Description
1Z0-042 Oracle Database 10g: Administration I
Oracle 1Z0-042 Study Guide
Oracle 1Z0-042 Study Guide © 2005 Self Test Software, a Kaplan IT Company. All rights reserved. No part of this study guide may be used or reproduced in any manner whatsoever without written permission of the copyright holder. The information contained herein is for the personal use of the reader and may not be incorporated in any commercial programs, other books, databases, or any kind of software without written consent of the publisher. Making copies of this study guide or any portion for any purpose other than your own is a violation of United States Copyright laws. Information has been obtained by Self Test Software from sources believed to be reliable. However, because of the possibility of human error by our sources, Self Test Software, or others, Self Test Software does not guarantee the accuracy, adequacy, or completeness of any information in this study guide and is not responsible for any errors or omissions or the results obtained from use of such information. Oracle® is a registered trademark of Oracle in the United States and/or other countries.
Self Test Software A Kaplan IT Company 500 Northridge Road Suite 240 Atlanta, Georgia 30350 800-244-7330 www.selftestsoftware.com
2 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Contents Contents......................................................................................................................... 3 Pass the Exam with the Self Test Study Guide ............................................................................................ 5
Introducing Oracle 10g Database: Oracle 10g Administration I................................ 6 Installing Oracle 10g Database..................................................................................................................... 7 Identifying the Components of Oracle Architecture .................................................................................... 13 Review Checklist: Introducing Oracle 10g Database: Oracle 10g Administration I .................................... 21
Creating and Controlling Databases: Oracle 10g Administration I......................... 22 Describing Oracle Enterprise Manager....................................................................................................... 23 Using Database Configuration Assistant .................................................................................................... 25 Controlling a Database................................................................................................................................ 36 Review Checklist: Creating and Controlling a Database: Oracle 10g Administration I .............................. 41
Managing Database Storage and Schema Objects: Oracle 10g Administration I . 42 Managing Database Storage ...................................................................................................................... 43 Working with Schema Objects .................................................................................................................... 50 Review Checklist: Managing Database Storage and Schema Objects: Oracle 10g Administration I ........ 58
Managing Data and Programming with PL/SQL: Oracle 10g Administration I....... 59 Using Database Interfaces.......................................................................................................................... 60 Manipulating Data using Data Manipulation Language Statements ........................................................... 62 Using Data Pump and SQL*Loader ............................................................................................................ 65 Programming with PL/SQL.......................................................................................................................... 72 Review Checklist: Managing Data and Programming with PL/SQL: Oracle 10g Administration I.............. 78
Managing Users and Securing Databases: Oracle 10g Administration I ............... 79 Administering Database Users ................................................................................................................... 80 Securing Databases.................................................................................................................................... 90 Review Checklist: Managing Users and Securing Databases: Oracle 10g Administration I ...................... 99
Working with Oracle Net Services: Oracle 10g Administration I........................... 100 Working with Oracle Net Services ............................................................................................................ 101 Managing Oracle Listeners and Configuring Oracle Net Services on Oracle Server ............................... 104 Configuring Client and Middle-tier Connection ......................................................................................... 117 Review Checklist: Oracle 10g Administration 1: Working with Oracle Net Services ................................ 119
Working with Oracle Shared Server: Oracle 10g Administration I........................ 120 Specifying the Need and Architecture of Shared Server .......................................................................... 121 Configuring Oracle Shared Server............................................................................................................ 123 Monitoring Oracle Shared Server ............................................................................................................. 129 Review Checklist: Working with Oracle Shared Server: Oracle 10g Administration I .............................. 133
Performance Monitoring and Proactive Maintenance: Oracle 10g Administration I .................................................................................................................................... 134 Performance Monitoring............................................................................................................................ 135 Proactive Maintenance.............................................................................................................................. 143 Review Checklist: Performance Monitoring and Proactive Maintenance: Oracle 10g Administration I.... 153
Maintaining Consistency and Concurrency in Databases: Oracle 10g Administration I ......................................................................................................... 154 Performing Undo Management................................................................................................................. 155 Monitoring and Resolving Lock Conflicts .................................................................................................. 161
3 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Maintaining Consistency and Concurrency in Database: Oracle 10g Administration I .................................................................................................................................................................. 165
Performing Database Backup and Recovery: Oracle Database 10g Administration I ................................................................................................................................... 166 Describing the Basics of Database Backup, Restore, and Recovery....................................................... 167 Performing and Managing Database Backups ......................................................................................... 170 Performing Database Recovery................................................................................................................ 179 Review Checklist: Performing Database Backup and Recovery: Oracle Database 10g Administration I 189 Taking the Test Strategies ........................................................................................................................ 190 Thank You and Good Luck on your Exams! ............................................................................................. 193
4 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Pass the Exam with the Self Test Study Guide As a certification candidate, you’re on the lookout for as many test preparation resources as possible, but your time is at a premium. So, we put together the Study Guide with your study goals and busy schedule in mind. Create a study plan – and stick to it. Don’t try to cram. Set aside specific study times so you can thoroughly prepare for your exam. In our experience, following a disciplined prep schedule leads to success on Exam Day. To thoroughly gain the benefits of our Study Guide, we recommend that you start preparing about six weeks prior to taking your exam. Use all the prep tools in your Study Guide. Your Guide contains a full suite of products to help you thoroughly prepare for your exam. Each one is designed with a specific study purpose in mind. Here’s how we recommend you use the products together: 1.
Perform a baseline checkup. Set your personal baseline by taking the Self Test Practice Test in Certification Mode. It is a timed test that simulates the real exam. Objective-based scoring shows you the areas you are relatively strong in, and those you need to devote additional time to.
2.
Concentrate your studies by objective. Since your study time has to be in chunks, use the exam’s structure by objective to help you organize your study sessions. Use each product to study at the objective level with particular emphasis on the objectives where you did not score 100% in your baseline checkup. •
• • • 3.
Study Guide. Read the Study Guide by objective to familiarize yourself with the exam content. The Study Guide is objective-driven and contains a Scope and Focused Explanation for each objective. At the end of each major objective is a Review Checklist that lists the key points covered in this area of the exam. Self Test Flash Cards. Drill through the Flash Cards by objective to be sure you know the fundamental concepts. Make Personal Study Notes with these cards to supplement your learning. Self Test Practice Test. Use the Practice Test in Learning Mode by objective. Answer the questions, read the tutorials, and use the Personal Study Notes to supplement your learning and/or highlight items that you’ll want to review before the exam. References. Use your favorite references (books, web references, etc.) to get additional materials on more complex subject matter.
Track your progress. You’ve completed your objective-driven study plan. Now you’re ready to see how you’ve progressed. Take the Self Test Practice Test in Certification Mode again. Did you score 100%? If not, go back to your objective study plan and focus on your weaknesses. Keep checking yourself, highlighting objectives that you’ll need to study, until you consistently score 100%.
Do your final preparation. Print the Review Checklists from the Study Guide and the Personal Study Notes from the Self Test Practice Test and Flash Cards. Use these as your condensed final review before taking the real exam. And, before taking the real exam, read the Test-Taking Strategies at the end of this guide to get specific techniques on approaching the different question types you may encounter. Finally, some last words of advice. During your studies and practice test drills, concentrate on the process - not totally on performance. What matters most is that you are using a disciplined approach that covers the materials on the exam and you know what to expect on exam day. Stay the course of your study plan and you will be ready to PASS THE EXAM!
5 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Introducing Oracle 10g Database: Oracle 10g Administration I
6 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Installing Oracle 10g Database Scope •
Identify system requirements for installing Oracle 10g.
•
Learn how to plan the Oracle 10g installation using Optimal Flexible Architecture (OFA) model.
•
Understand the benefits of installing Oracle 10g using Oracle Universal Installer (OUI).
Focused Explanation Oracle 10g Installation Requirements To install and run an instance of Oracle 10g, you need to verify various installation requirements, such as the release level of the operating system on which installation will be performed, memory requirements, CPU resources, and disk storage space. The following are some hardware requirements for installing Oracle 10g on the Windows platform: •
Memory: Requires a minimum of 256 MB of RAM, but the recommended memory is 512 MB.
•
Free disk space: Requires a minimum of 1.5 GB available disk space for the Oracle 10g installation. Additionally, Database Configuration Assistant (DBCA) requires 1 GB for creating a database.
•
Swap space: Requires 1 GB or two times the storage capacity of RAM.
•
Temporary space: Requires 100 MB of disk space in the temp directory.
The following are the hardware requirements for installing Oracle 10g on the Linux and UNIX platforms: •
Memory: Requires a minimum of 512 MB of RAM.
•
Free disk space: Requires a minimum of 2.5 GB available disk space for the Oracle 10g software installation. Additionally, DBCA requires 1.2 GB for creating a database.
•
Swap space: Requires 1 GB or two times the storage capacity of RAM.
•
Temporary space: Requires 400 MB of disk space in the temp directory.
Oracle Universal Installer (OUI) checks for installation requirements before installing Oracle 10g. OUI aborts and stops the installation process if the installation requirements for Oracle 10g are not fulfilled. You can override this and install the software without the prerequisites being met by providing the ignoreSysPrereqs option. Planning Installation using Optimal Flexible Architecture Model You can plan the installation of Oracle 10g using the Optimal Flexible Architecture (OFA) model. Though mainly used for managing Oracle installation on UNIX, this model can also be used for managing
7 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
installation on Windows. The OFA model provides naming conventions for UNIX file systems, mount points, directory paths, database files, and Oracle-related files. Every file on the UNIX platform belongs to an operating system user account. Therefore, before installing Oracle 10g on UNIX, you need to create an operating system user account. Each operating system user account on UNIX belongs to one or more operating system groups. You need to create an operating system group for the operating system user accounts of Oracle files. The common names recommended in the OFA model for the operating system user accounts of Oracle 10g are oracle, oracle10g, and ora101. The operating system group that owns the operating system user accounts of Oracle is called dba. UNIX installs Oracle files in logical storage areas called volumes. A UNIX system administrator mounts or attaches these logical storage areas to mount points or directories. The OFA model suggests a naming convention for these directories and mount points. This naming convention specifies that the name of directories and mount points should consist of a combination of character and numeric values. For example, you can specify names, such as /mnt01 and /d01, for mount points and directories on UNIX. The OFA model specifies that the directory structure under the mount points should use meaningful naming conventions. For example, a directory structure under a mount point represented as /u01/app/oracle shows that the Oracle files are installed as an application under mount point u01 of UNIX. The OFA model also specifies operating system environment variable names for some of the directory paths. For example, the $ORACLE_HOME environment variable is used to represent the directory path where Oracle 10g is installed. These environment variables help to navigate and provide portability of the directory structure. For example, for the top-level directory of Oracle software on a host server, the OFA model specifies environment variables $ORACLE_BASE on UNIX and %ORACLE_BASE% on Windows. The following are some environment variables: •
ORACLE_BASE – Represents the top-level directory of Oracle software on the host server.
•
ORACLE_HOME – Represents the directory into which the Oracle 10g software is installed.
•
ORACLE_SID – Defines the database instance to which an operating system user session can connect.
•
TNS_ADMIN – Specifies the directory where Oracle Net configuration files are stored.
•
LD_LIBRARY_PATH – Is used on a UNIX operating system to specify the location of the Oracle shared object library.
•
PATH – Specifies the directory that contains executable files of Oracle software.
8 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The OFA model also provides naming conventions for physical database files. Oracle contains three types of physical database files: •
control files
•
datafiles
•
redo log files
Control files use names such as controln.ctl, where n specifies a unique number for duplicate copies of the control file. For example, control01.ctl, control02.ctl, and control03.ctl are the names for multiple copies of a control file. Datafiles use names such as filenamen.dbf, where n is the number of the datafile in a tablespace. A tablespace is a logical storage area that can contain one or more physical datafiles to store data. The name of datafiles should also describe the tablespace to which they belong. For example, if a tablespace, USERS, is composed of three datafiles, the name of these datafiles will be users01.dbf, users02.dbf, and users03.dbf. The OFA model specifies the name redogm.log for redo log files, where g specifies the group number of the redo log and m is the number of the member file in a particular redo log group. For example, if the database has three redo log groups and each redo log contains two members, the name of files for the first redo log group will be redo1a.log and redo1b.log. Similarly, the name of files for the second redo log group will be redo2a.log and redo2b.log. Installing Oracle 10g Using Oracle Universal Installer on Windows You can install Oracle 10g using Oracle Universal Installer (OUI), which is a Java-based Graphical User Interface (GUI) application. When you insert the Oracle 10g CD, OUI is invoked automatically on the Windows platform. You can also invoke OUI manually by double-clicking the setup.exe file icon, which is located in the root folder of the Oracle 10g CD. On the UNIX platform, you need to run the runInstaller script to install Oracle 10g. Before installing Oracle 10g, the OUI performs some installation checks to install both Oracle 10g software and database from a single CD or multiple CDs. These checks verify whether the operating system required to install Oracle 10g is configured or not. OUI checks all the resources required to install Oracle 10g before installing Oracle 10g. OUI verifies the following resources before installing Oracle 10g: •
Verifies whether the required version of the operating system, supported by Oracle 10g, is installed. For example, you can install Oracle 10g only on a Solaris 2.8, or later, version on the Sun platform.
•
Verifies all the kernel parameters required to install Oracle 10g on all UNIX platforms.
•
Verifies that the required swap space and temporary disk space is available.
•
Verifies that the $ORACLE_HOME folder, where you want to install Oracle 10g, is either empty or contains the supported version of software components.
9 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Verifies that the required operating system patches are installed.
•
Verifies that 32-bit Oracle 10g components are not installed in the folder where you want to install 64-bit Oracle 10g, and vice versa.
To install Oracle 10g on Windows using OUI, complete the following steps: 1. Double-click the icon of the setup.exe file for Oracle 10g. The Welcome to the Oracle Database 10g Installation screen is displayed. 2. Click Next to continue. The Specify File Locations screen is displayed. Figure 1-1 shows the Specify File Locations screen.
Figure 1-1: The Specify File Locations Screen 3. In the Path text box of the Destination pane, type the location to which to install Oracle 10g database software. 4. Click Next to continue. The Select Installation Type screen appears. This screen displays the following options: •
Standard Edition – Installs an integrated set of management tools, Web features, and products for creating business-related applications.
10 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Enterprise Edition – Installs licensable Oracle Database options and database configuration and management tools, in addition to all the products installed during the Standard Edition installation. This edition also installs the products for data warehousing and transaction processing applications.
•
Personal Edition – Supports only a single-user development environment.
•
Custom – Allows you to install components of Oracle 10g individually.
5. Select the Enterprise Edition option for installing all available Oracle 10g features. 6. Click Next to continue to the Select Database Configuration screen. This screen shows the options to create a starter database. 7. Select the Do not create a starter database option. 8. Click Next to continue to the Summary screen. This screen shows all the options that you selected on previous screens and lists all the components that will be installed. 9. Click Install to continue to the Install screen. This screen shows a progress bar to indicate the progress of the installation process. When the installation is complete, the End of Installation screen is displayed. 10. Click Exit to exit the installation. Installing Oracle 10g on Linux Using OUI To install Oracle 10g on Linux using OUI, complete the following steps: 1. Set the following environment variables: •
$ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
•
$ORACLE_HOME=$ORACLE_BASE/product/10.1.0; export ORACLE_HOME
•
$ORACLE_SID=orcl; export ORACLE_SID
•
$PATH=$ORACLE_HOME/bin:$PATH; export PATH
•
$LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
2. Start the OUI using the runInstaller.sh command: $ /mnt/cdrom/runInstaller This command starts the OUI, which then checks for installation requirements to install Oracle 10g. 3. Click Next to continue.
11 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The Specify Inventory directory and credentials screen is displayed. Type the full path of the inventory directory and operating system group name in the Enter the full path of the inventory directory text box. The inventory directory stores the installer files to install Oracle products. A pop-up window is displayed. This window shows that you need to run the orainstRoot.sh script as root from the directory specified in this pop-up window. 4. Run the orainstRoot.sh script from the Linux command line. This script file creates the Inventory pointer file, named oraInst.loc, which directs OUI to the directory path of the inventory location. 5. Click Next to continue. The Specify File Locations screen is displayed. 6. In the Path text box of the Destination pane, type the location to which to install Oracle 10g database software. 7. Click Next to continue. The Select Installation Type screen is displayed. 8. Select the Enterprise Edition option for installing all available Oracle 10g features. 9. Click Next to continue. The Product-specific Prerequisite screen is displayed. This screen shows the verification of operating system version and configuration for installing the Enterprise Edition of Oracle 10g. 10. Click Next to continue. The Select Database Configuration screen is displayed. This screen shows the options to create a starter database. 11. Select the Do not create a starter database option. 12. Click Next to continue. The Summary screen is displayed. This screen shows all the options that you selected and lists all the components that will be installed. 13. Click Install to continue. The Install screen is displayed. This screen shows a progress bar to indicate the progress of the installation process. A pop-up window is displayed at the end of the installation process, displaying the configuration information. 14. Click OK to continue. The Setup Privileges pop-up window is displayed. This window shows that you need to run a configuration script, root.sh, as root from a directory path specified in this window. 15. Run the root.sh script from the Linux command line. This script prompts for the location of the local /bin directory. Accept the default location by pressing Enter. 16. Return to the Setup Privileges window and click OK to continue. The End of Installation screen is displayed. 17. Click Exit to exit from the installation process.
12 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Identifying the Components of Oracle Architecture Scope •
Describe the architecture of an Oracle instance and Oracle database.
Focused Explanation Oracle Instance Architecture Oracle instance architecture represents the logical memory structure of the Oracle Server. The Oracle instance contains two components: •
System Global Area (SGA)
•
Oracle background processes
SGA The SGA is a shared memory area that Oracle uses to store data and control information for an Oracle instance. It is allocated when an Oracle instance is initiated, and de-allocated when the Oracle instance shuts down. The SGA represents a set of memory blocks that are shared among all the users connected to the Oracle database. The components of the SGA contain data and control information of the Oracle database. The following are the various components of the SGA: •
Shared pool
•
Database buffer cache
•
Redo Log buffer
•
Java pool
•
Large pool
•
Streams pool
Shared pool – Represents the memory area that stores data dictionary cache and library cache. The data dictionary cache contains structural and data information, such as names of datafiles, names of segments, locations of extents, descriptions of tables, and privileges. The library cache stores the execution plan of a SQL query and the parse tree of commonly used SQL statements. The shared pool is a required component of the SGA. Database buffer cache – Represents the memory area that caches the most recently used data blocks. This component is a required component of the SGA. The database buffer cache contains four types of buffers: •
Dirty Buffers – Contain data that has been modified but not written to the disk.
•
Free Buffers – Contain data that has been written to disk and available to be overwritten.
13 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Pinned Buffers – Represent buffer blocks that are currently being accessed.
•
Cleaned Buffers – Represent the buffers that are unpinned. These buffers can be aged out if their contents are not referenced again.
Note: Oracle uses the Least Recently Used (LRU) algorithm to manage the shared pool and database buffer cache. This algorithm identifies the least recently used SQL statements or data blocks and uses their space to store new SQL statements or data blocks. Redo log buffer – Represents the memory area that stores information about database transactions. This component of the SGA contains information about the changes made to the data in a database. The information in this component is used for recovery from a database failure. The redo log buffer is a required component of an Oracle instance. Java pool – Represents the memory area that stores information about most recently-used application code and objects of Java. This component is an optional component of the SGA. The Java pool is used when you work with a Java application that interacts with the Oracle database. Large pool – Represents an optional memory area of the SGA that caches information for operations, such as database backup and restore. This component of the SGA also caches message buffers for parallel query. Streams pool – Represents an optional component of the SGA that stores information about queued message requests when the advanced queuing option of Oracle is used. Managing the SGA Oracle provides two ways to manage the size of the SGA components: •
Manual shared memory management
•
Automatic shared memory management
With manual shared memory management, you need to specify the initialization value for each component of the SGA. You can change the initialization values for SGA components according to the requirements of the application that interacts with the Oracle database. Oracle 10g also provides Automatic Shared Memory Management for managing the SGA. This shared memory management feature automatically sizes database buffer cache, shared pool cache, large pool, and Java pool components of the SGA. These components of the SGA are called auto-tuned components. You can manage other SGA components manually. These components are called manually-managed SGA components. Oracle divides memory allocated to the SGA into chunks called granules. The size of the granules is determined according to the value of the SGA_MAX_SIZE parameter. The value of this parameter specifies the maximum size of the SGA. The size of granules is 4 MB if the total size of the SGA is less than 128 MB, and 16 MB if the total size of the SGA is greater than 128 MB.
14 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Oracle Background Processes Oracle background processes help manage an Oracle instance. The background processes help to maintain and enforce the relationship between physical file structures and logical memory structures of a database. An Oracle instance contains five required Oracle processes and several optional background processes. The following are the required Oracle background processes: •
System Monitor (SMON)
•
Process Monitor (PMON)
•
Database Writer (DBWR)
•
Log Writer (LGWR)
•
Check Points (CKPT)
The SMON process uses online redo log files to perform instance or crash recovery. This process also performs monitoring of temporary segments and extents. The SMON process cleans up the temporary segments that are no longer in use. This process also collects the contiguous free space from the tablespace to create larger free extents. Oracle periodically calls the SMON process to check whether this process is needed. Other processes can call the SMON process if they detect a need for this process. The PMON process performs clean up and resource recovery of failed user processes. This process takes back resources from failed user processes and releases the locks on tables and rows held by a database user. Oracle periodically calls the PMON process to check whether this process is required. The DBWR process writes dirty buffers from database buffer cache to database datafiles. This process writes to database datafiles when: •
A transaction is committed
•
The database buffer cache is full and needs free space to store new data blocks
•
A checkpoint occurs
•
A timeout occurs
•
A tablespace is changed to read-only
•
A tablespace is placed offline
•
A table is dropped or truncated
•
A tablespace is placed in backup mode
An Oracle instance contains at least one or more DBWn processes. An Oracle instance can have a maximum of 20 DBWn processes, where the value of n is from 0 to 9 and a to j. For example, if an Oracle instance contains three DBWn processes, the name of these processes will be DBW0, DBW1, and DBW2.
15 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The LGWR process writes the information from the redo log buffer component of the SGA to online redo log files. This process writes information when: •
A transaction is committed.
•
The redo log buffer is one-third full.
•
A DBWn process writes dirty buffer blocks to datafiles.
•
A time period of three seconds has elapsed.
•
The size of redo records exceeds 1 MB.
•
The LGWR process performs two operations simultaneously: o
Writes the redo log buffer information to a redo log file.
o
Allows the Oracle Server processes to write to the redo log buffer.
The CKPT process updates the datafiles and control files when a checkpoint event occurs. This event flushes dirty blocks from the buffer cache to database datafiles. Checkpoint events take place when a log switch occurs. A log switch occurs when an online redo log file fills and Oracle starts writing to the next redo log file. The following are some of the optional background processes in Oracle 10g: •
Archiver (ARCn) – Copies the information written by LGWR to online redo log files and to a secondary location for recovery.
•
Recoverer (RECO) – Recovers failed transactions that are distributed across multiple databases when using the distributed database feature of Oracle.
•
Job Queue Monitor (CJQN) – Allocates jobs to job queue processes, using the job-scheduling feature of Oracle.
•
Job Queue (Jnnn) – Executes jobs that are scheduled using the job-scheduling feature of Oracle.
•
Queue Monitor (QMNn) – Monitors messages in a message queue when the Advanced Queuing (AQ) feature of Oracle is used.
•
Parallel Query Slave (Qnnn) – Executes parts of a large query when the parallel query feature of Oracle is used.
•
Dispatcher (Dnnn) – Minimizes resources required by handling multiple connections to the database using a limited number of server processes. Dispatcher processes assign database requests of users to a queue where they are processed by Oracle shared server processes. Shared server processes are used when the shared server feature of Oracle is used.
16 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Shared Server (Snnn) – Creates server processes that are shared among database users when the shared server feature of Oracle is used.
•
Memory Manager (MMAN) – Manages auto-tuned components of the SGA when the Automatic Shared Memory Management feature of Oracle is used.
•
Memory Monitor (MMON) – Collects and analyzes statistics used by the Automatic Workload Repository (AWR) feature of Oracle.
•
Recovery Writer (RVWR) – Writes recovery information to the disk when the flashback recovery feature of Oracle is used.
•
Change Tracking Writer (CTWR) – Maintains a record of database blocks that have changed when the incremental recovery feature of Oracle is used.
Configuring an Oracle Instance An Oracle instance is configured according to the settings in a configuration file, called a parameter initialization file. This file can be of two types: •
Parameter Files (PFILES)
•
Server Parameter Files (SPFILES)
Oracle 10g provides more than 250 parameters for configuring Oracle instances. These parameters are stored in a parameter initialization file. Configuration parameters are categorized into two groups: •
Basic initialization parameters – Represent a set of approximately 30 initialization parameters, which are recommended by Oracle to be set manually.
•
Advanced initialization parameters – Represents the other initialization parameters, which are stored with their default values. These parameters are set manually only if Oracle support recommends them to meet the specific needs of your application.
The following are some basic initialization parameters specified in the parameter initialization file: •
CLUSTER_DATABASE – Specifies whether Real Application Clusters (RAC) is enabled. The default value of this parameter is FALSE. Note: RAC is a computing environment that uses the processing power of multiple, interconnected computers on a network.
•
COMPATIBLE – Enables you to use the new version of Oracle, while maintaining backwardcompatibility with the earlier versions installed on your computer.
•
CONTROL_FILES – Specifies the name of the control file(s) associated with a database.
•
DB_BLOCK_SIZE – Specifies the size of a database block, in bytes.
•
DB_CREATE_FILE_DEST – Specifies the default location for Oracle-Managed Files (OMF).
17 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
DB_CREATE_ONLINE_LOG_DEST_n – Specifies the default location of control files and online redo logs.
•
DB_DOMAIN – Specifies the location of a database on a computer network.
•
DB_NAME – Specifies the name of a database.
•
DB_RECOVERY_FILE_DEST – Specifies the default location of the flash recovery area. The flash recovery area contains duplicate copies of current control files, online redo logs, archived redo logs, and backup files.
•
DB_RECOVERY_FILE_DEST_SIZE – Specifies the size of the flash recovery area, in bytes.
•
DB_UNIQUE_NAME – Specifies the globally-unique name of a database. Databases with the same DB_NAME parameter are identified with the DB_UNIQUE_NAME parameter.
•
INSTANCE_NUMBER – Specifies a number that maps a database instance to an integer. This integer is used to identify a database instance in a RAC environment.
•
JOB_QUEUE_PROCESSES – Specifies the maximum number of processes that can be created by Oracle 10g for executing jobs submitted through Enterprise Manager or DBMS_JOBS.
•
LOG_ARCHIVE_DEST_n – Specifies archive log destination locations. You can specify up to 10 archive log destinations.
•
LOG_ARCHIVE_DEST_STATE_n – Specifies the availability state of the corresponding archive log destination locations.
•
NLS_TERRITORY – Specifies the name of the geographical location whose conventions are to be followed for day and week numbering in Oracle 10g.
•
NLS_LANGUAGE – Specifies the default language of a database.
•
OPEN_CURSORS – Specifies the maximum number of open cursors in a user session.
•
PGA_AGGREGATE_TARGET – Specifies the Program Global Area (PGA) memory available to all the processes associated with a database instance.
•
PROCESSES – Specifies the number of operating system processes that can connect to Oracle 10g simultaneously.
•
REMOTE_LISTENER – Specifies a network name that maps to the addresses of Oracle Net Remote listeners.
•
REMOTE_LOGIN_PASSWORDFILE – Specifies whether Oracle 10g checks for a password file. This parameter also specifies the number of databases that can be used in that password file.
•
ROLLBACK_SEGMENTS – Allocates one or more rollback segments to the current database instance.
18 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
SESSIONS – Specifies the maximum number of sessions that can connect to a database instance.
•
SGA_TARGET – Specifies the size of the System Global Area (SGA) for auto-tuned SGA components, when the Automatic Shared Memory Management feature of Oracle is used.
•
SHARED_SERVERS – Specifies the maximum number of shared server processes that are created when a database instance is started.
•
STAR_TRANSFORMATION_ENABLED – Specifies whether a cost-based query transformation will be applied when database queries are executed.
•
UNDO_MANAGEMENT – Specifies whether the undo space management is automatic or manual.
•
UNDO_TABLESPACE – Specifies the name of the undo tablespace that Oracle 10g uses when a database instance is started.
Oracle Database Architecture Oracle database architecture represents the physical file structure of the Oracle Server. The Oracle database contains physical files, which are stored on the disk drive of a host server. An Oracle database contains three types of physical files: •
Control files
•
Datafiles
•
Redo log files
Control files contain information, such as database name, database block size, database character set, database recovery information, and locations of datafiles and redo log files. Control files are created at the locations specified in the CONTROL_FILES parameter of the initialization parameter file. Oracle stores multiple copies of control files at multiple locations to facilitate database recovery. The CKPT background process automatically updates all the copies of the control files required to maintain consistency of information in all copies of the control files. You can view the names and locations of all the control files by querying the V$CONTROLFILE view. Datafiles store the data inserted into the tables of a database. The size of a datafile is proportional to the amount of table data that it stores. Every Oracle database needs to have one or more datafiles. Each datafile belongs to a particular tablespace, which can contain more than one datafile. The database logically groups related data into tablespaces. For example, a database groups data related to a particular application or function in one or more tablespaces. The tablespaces are composed of segments. Any database object that requires physical storage is called a segment. A database segment can be a table, an index, a rollback, or a partition. Each segment is composed of extents. A segment contains a minimum of one extent and can have a maximum two billion extents. The extents are composed of a minimum of five data blocks. The data blocks are of sizes 2 KB, 4 KB, 8 KB, or 16 KB. A data block is the smallest unit of storage used by an Oracle database. The operating system files can be of sizes 512 bytes to 2 KB.
19 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Every Oracle 10g database must contain the following three tablespaces: •
SYSTEM – Contains data dictionary tables and PL/SQL code.
•
SYSAUX – Contains segments used for database options, such as Automatic Workload Repository (AWR) and Online Analytical Processing (OLAP).
•
TEMP – Contains temporary data that Oracle generates when processing queries, sorting, and performing database updates. This tablespace is required if the SYSTEM tablespace is created as a locally-managed tablespace.
The Oracle database can also contain other tablespaces, such as TOOLS, USERS, and UNDOTBS1. Redo log files contain information about all changes to datafiles in a database. Whenever a change to a datafile takes place in a database, the information to reproduce the change is stored in the redo log buffers. If recovery is necessary, Oracle uses this information to return the database to its prior state. The LGWR background process writes this information to online redo log files. Oracle creates multiple copies of redo log files at multiple locations because these files are used in recovery of an Oracle database. The set of copies of a redo log file is called a redo log group, and each redo log file in this set is called a redo log group member.
20 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Introducing Oracle 10g Database: Oracle 10g Administration I Identify the installation requirements for Oracle 10g. Discuss planning installation using OFA model. Describe Oracle 10g installation using OUI. Describe Oracle instance architecture. Describe Oracle database architecture.
21 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Creating and Controlling Databases: Oracle 10g Administration I
22 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Describing Oracle Enterprise Manager Scope •
Describe various components of Oracle Enterprise Manager.
Focused Explanation Introducing Oracle Enterprise Manager Oracle Enterprise Manager is a framework, which provides a set of tools that you can use to create Oracle databases and Oracle database objects. You also use the Enterprise Manager to manage Oracle database space and monitor the performance of an Oracle database. This framework provides Webbased interfaces for managing Oracle components. An Oracle component could be an Oracle database, an Oracle application server, or an application that interacts with an Oracle database. These Oracle components are called managed targets. Oracle Enterprise Manager uses Management Agents to communicate with managed targets. A Management Agent is a background process, which runs on host computers that contain managed targets. You can use the Management Agent to manage complex databases, such as a database distributed over geographical regions. Components of Oracle Enterprise Manager The following are the various components of Oracle Enterprise Manager: •
Managed Targets – Represents Oracle components that are managed using Oracle Enterprise Manager.
•
Oracle Management Service – Represents the interface, which is used to monitor and control managed targets. This interface is a Java-based Web component.
•
Management Repository – Stores monitoring and configuration information about managed targets. The management repository consists of two tablespaces in an Oracle database.
•
Oracle Enterprise Manager 10g Grid Control – Provides a Web-based interface to manage Oracle Server services, such as Oracle application servers, Oracle databases, and Oracle applications, from a centralized location.
•
Oracle Enterprise Manager 10g Database Control – Provides a Web-based interface to manage an Oracle database instance or a Real Application Cluster (RAC). Note: RAC is an Oracle database component that allows a database to be installed across multiple servers.
•
Application Server Control – Provides a Web-based interface to manage an instance of an Oracle application server, a collection of instances of Oracle application servers, or a cluster of instances of Oracle application servers.
23 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Controlling Oracle Management Agents An Oracle Management Agent collects information about all managed targets and communicates with Oracle Management Service to store this information in the management repository. For example, a Management Agent monitors an Oracle database and sends an alert to the management service, if the database is not available. The Oracle Management Service transfers information collected by Management Agents to Oracle Enterprise Manager Grid Control. You must start the Management Agent on each host computer of the managed targets to collect information about them. You use the emctl command-line utility to start and stop the Management Agent. This utility is stored in the ORACLE_HOME/bin directory. You can issue the emctl start agent command to start the Management Agent, and the emctl stop agent command to stop the Management Agent. Note: ORACLE_HOME is the directory where Oracle 10g software is installed. Using Oracle Enterprise Manager 10g Database Control Oracle Enterprise Manager 10g Database Control is a Web-based tool that helps to manage an instance of a database. To access this tool, you must start the Database Control Agent, which is a background process that collects information about an instance of a database. The emctl start dbconsole command is used to start the Database Control Agent. The emctl program is stored in the ORACLE_HOME/bin directory. You can issue the emctl stop dbconsole command to stop the Database Control Agent, and the emctl status dbconsole command to determine whether or not the Database Control Agent is running. After the Database Control Agent is running, you can access the Oracle Enterprise Manager 10g Database Control tool. To access it, type the address http://hostname:portnumber/em in the Address bar of the Web browser. You can use this tool to perform various administrative tasks, such as starting and shutting down a database. Note: The default port for Database Control is 5500. You can obtain the information about the port numbers being used by various Oracle components, from the portlist.ini file. This file is located in the ORACLE_HOME/install directory.
24 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Using Database Configuration Assistant Scope •
Identify the steps to create, configure, and drop a database.
•
Understand how to manage database templates using Database Configuration Assistant (DBCA).
Focused Explanation Introducing Database Configuration Assistant Oracle Database Configuration Assistant (DBCA) is a Java-based tool that provides a Graphical User Interface (GUI) to create, configure, and drop databases. This tool can also be used for managing database templates. A database template is an XML file that stores the definition of the database configuration. You can invoke the DBCA tool on Windows by selecting Start -> Programs -> Oracle Oracle Home -> Configuration and Migration tools -> Database Configuration Assistant. You can also invoke this tool from the command line by issuing the dbca command. The DBCA utility is stored in the ORACLE_HOME/bin directory. Creating and Configuring a Database To create a database using DBCA, complete the following steps: 1. Invoke the Database Configuration Assistant. The Welcome screen is displayed. 2. Click Next to continue. The Operations screen is displayed. It displays the following options: •
Create a Database – Creates a database. You can create a database using an existing template or create a customized database according to the requirements of your organization.
•
Configure Database Options – Enables you to change the configuration definition of an Oracle server to move it from a dedicated Oracle server to a shared Oracle server. This option enables you to add database options that you have not previously configured for the database.
•
Delete a Database – Removes a database and all its associated files.
•
Manage Templates – Manages database templates.
3. Select the Create a Database option.
25 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
4. Click Next to continue. The Database Templates screen is displayed. The following are the database options available on the Database Templates screen: •
Custom
•
Data Warehouse
•
General Purpose
•
Transaction Processing
These options are used to create databases that are optimized for a particular workload. For example, you can select the Transaction Processing option to create an Oracle database optimized for transaction processing or the Data Warehouse option for creating an Oracle database optimized for data warehousing. 5. You can select an option from the Database Templates screen and click Show View to view the configuration definition of a template. The configuration definition of a template contains the following fields: •
Common Options – Shows which options will be installed for a database.
•
Initialization Parameters – Shows initialization parameters for a database and their settings.
•
Character files – Displays the character set used in a database.
•
Tablespaces – Shows the name and type of tablespaces in a database.
•
Datafiles – Shows the name and size of datafiles for each tablespace in a database.
•
Redo Log groups – Shows the number and size of redo logs for a database.
6. Select the option from the Database Templates screen to create a new database. 7. Click Next to continue. The Database Identification screen is displayed. This screen contains Global Database Name and SID text boxes. The Global Database Name text box contains the fully-qualified name of a database. The format of this name is name.domain, where name represents the name of the database and domain represents the domain of the database within an enterprise. The database domain is the same as the network domain within the enterprise. A global database name needs to be unique within a network domain. The SID text box contains the Oracle System Identification (SID) name that represents the name of the database instance attached to a database. Each database instance associated with an Oracle database should have a unique SID name. The SID name can be a maximum of eight characters.
26 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
8. Type the database name and database SID name in the Global Database Name and SID text boxes, respectively. 9. Click Next to continue. The Management Options screen is displayed. Figure 2-1 shows the Management Options screen.
Figure 2-1: The Management Options Screen This screen displays the options that you can use to manage an Oracle database. There are two ways to manage the database: •
Manage each Oracle database centrally using Oracle Enterprise Manager 10g Grid Control
•
Manage each Oracle database as a separate entity using Oracle Enterprise Manager Database Control
Oracle 10g Enterprise Manager Grid control manages each database through a Management Agent. If the Management Agent is installed, DBCA detects the installed Oracle Management Agent and lists the names of the management services for the Management Agent. You can
27 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
select one of these management services to manage the database through the installed Management Agent. If the Management Agent is not installed and you want to manage the database as a separate entity, select the Use Database Control for Database Management option. From the Management Options screen, you can select Enable Email Notifications to enable the e-mail notification service. This service sends an e-mail message when database thresholds, such as the maximum number of database sessions, are reached. To configure the e-mail notification service, you must type the name of your SMTP mail server in the Outgoing Mail (SMTP) Server text box, and the e-mail address to which the notification should be sent in the Email Address text box. You can also select the Enable Daily Backup option to enable daily backups of your database. You must specify the backup start time and an operating system user name and password to configure backup options. Oracle Enterprise Manager starts the backup process at the specified start time using the given user account and password of the operating system. 10. Click Next to continue. The Database Credentials screen is displayed. This screen contains options to specify the passwords for the user accounts that will be created in the new database. The following are the user accounts created in a new database: •
SYS – Contains the data dictionary.
•
SYSTEM – Contains additional administrative views and tables.
•
DBSNMP – Provides a user account to Oracle Enterprise Manager for collecting performance statistics about the database.
•
SYSMAN – Creates and modifies administrator accounts of Oracle Enterprise Manager.
You can select the Use the Same Password for All Accounts option to specify the same password for all user accounts. You can select the Use Different Passwords option to specify a different password for each user account. 11. Click Next to continue. The Storage Options screen is displayed.
28 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 2-2 shows the Storage Options screen.
Figure 2-2: Storage Options Screen This screen provides options for configuring disk storage areas of a database. The following are the options for configuring the disk storage areas: •
File System – Specifies that the file system will be used for database storage. With this configuration, you can specify the names of datafiles and the locations for storing these datafiles. The File System option is selected by default.
•
Automatic Storage Management (ASM) – Specifies that ASM disk groups will be used for database storage. With this configuration, you can define disk groups instead of individually managing the datafiles. A disk group is a logical unit of one or more datafiles. ASM is a new feature available in Oracle 10g. If you select the ASM option, Oracle creates an additional database instance. This database instance manages the storage definition of the database to be created and keeps track of disk group allocation. This additional database instance is known as a secondary ASM database instance.
29 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Raw Devices – Specifies that raw disk partitions and volumes will be used for database storage. You can use this option if you have a disk that does not contain an operating system-managed file system. The read and write activities on the disk are performed by Oracle.
12. Accept the default option and click Next to continue. The Database File Location screen is displayed. This screen provides the following options: •
Use Database File Locations From Template – Stores the datafiles on locations specified in the configuration definition of the template selected for creating a new database. If you select this option, you can review and change the filenames and locations later when creating the database.
•
Use Common Location for All Database Files – Specifies a common directory for all datafiles. If you select this option, you can review and modify the file location later when creating the database.
•
Use Oracle-Managed files – Stores the datafiles to an area managed by a secondary ASM database instance. This option is used when you select the Automatic Storage Management (ASM) option on the Storage Options screen. This option does not allow you to modify the location of datafiles when creating a database.
13. Accept the default option and click Next to continue. The Recovery Configuration screen is displayed. This screen contains two options for database recovery: •
Specify Flash Recovery Area – Is a new option in Oracle 10g that uses the flash recovery area to perform database recovery. A flash recovery area is an area of the disk that stores and manages files required for database recovery.
•
Enable Archiving – Enables the archive logging process. This process enables you to perform point-of-failure recovery of database. After selecting Enable Archiving, you can view and modify the parameters that are used to configure archive logging.
14. Accept the default option and click Next to continue. The Database Content screen is displayed.
30 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
If you select the Custom option from the Database Templates screen, the Database Content screen will contain the options shown in Figure 2-3.
Figure 2-3: Database Content Screen You can use the options on this screen to select the Oracle database components that you want to install. The following are the various options on this screen: •
Oracle Text – Supports multimedia content, such as audio and video.
•
Oracle OLAP – Provides support for creating and deploying online analytical processing applications.
•
Oracle Spatial – Manages geographical and spatial information, such as map coordinates.
•
Oracle Data Mining – Provides a set of tools and algorithms to support data mining.
•
Oracle Ultra Search – Provides search capabilities across different data repositories, including Oracle databases, mail servers, Web servers, and file systems.
•
Oracle Label Security – Secures information stored in a database.
31 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Sample Schemas – Creates sample schemas that provide examples on how to configure and use features of the Oracle database.
•
Enterprise Manager Repository – Provides the location of the schema that is used for managing the Management Repository.
If you select the General Purpose option on Database Templates screen, the Database Content Screen will contain the options shown in Figure 2-4.
Figure 2-4: Database Content Screen 15. Select the Sample Schemas check box in the Sample Schemas tab page of the Database Content screen to install the sample schemas. 16. Accept the default option and click Next to continue. The Initialization Parameters screen is displayed.
32 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
This screen helps you to set the various initialization parameters for configuring the database instance. This screen contains four tabs: •
Memory – Contains two options, Typical and Custom. The Typical option allocates memory to the components of the System Global Area (SGA) and the Process Global Area (PGA). The memory allocation process is automatic and uses a percentage of total memory available on the server. The default percentage of memory used by this process is 40 percent. You can click the Show Memory Distribution button to view the memory distribution between the SGA and PGA. The Custom option allows you to manually allocate the memory to the components of the SGA and PGA. These components are the shared pool, the buffer cache, the Java pool, the large pool, and PGA size.
•
Sizing – Provides options to specify the block size of a database and the maximum number of simultaneous Oracle processes that can connect to this database.
•
Character Sets – Provides the options to set the character set, the national character set, the default language, and the default date format. A character set defines how characters are stored and displayed within an Oracle database. The national character set determines the view of Unicode characters in an Oracle database, if the Oracle database does not use a Unicode-enabled character set. The default language setting determines how an Oracle database displays time and monetary values. The default date setting determines how an Oracle database displays dates.
•
Connection Mode – Provides two options that specify the type of connection to be used for this database. The following are the options for the database connection mode: o
Dedicated Server Mode – Allocates a resource dedicated to a client connection to the database. This mode is used when the number of client connections is small and the client makes persistent and long-running requests to the database.
o
Shared Server Mode – Shares a pool of resources among the client connections to the database. This mode is used when the number of client connections is large.
17. Select an option from the Connection Mode tab page. 18. Click Next to continue. The Database Storage screen is displayed. You can review and change the location of the datafiles, control files, and redo log files on this screen.
33 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
19. Click Next to continue. The Creation Options screen is displayed. This screen provides two options: •
Create Database – Creates a database immediately.
•
Save as a Database Template – Saves a database definition as a template, which you can later use to create a database.
20. Select the Create Database option. 21. Click Finish. The Confirmation screen is displayed. This screen shows the summary of the configuration options that you selected for creating a database. Configuring a Database Using DBCA You can review and change the configuration of an existing Oracle database using DBCA. To change the configuration of an existing database, perform the following steps: 1. Start the DBCA tool. The Welcome screen is displayed. 2. Accept the default option and click Next to continue. The Operations screen is displayed. Select the Configure Database Options option on the Operations screen. If the database is not started, the DBCA utility starts the database automatically. To configure the database, you must connect to the database as a user that has DBA authority. After selecting and starting the database, you can add options that are not currently installed in your database. Deleting a Database Using DBCA You can delete an existing database using DBCA. To delete a database, perform the following steps: 1. Start the DBCA tool. The Welcome screen is displayed. 2. Accept the default option and click Next to continue. The Operations screen is displayed. 3. Select the Delete A Database option on the Operations screen. 4. Accept the default option and click Next to continue. DBCA shows a list of all the existing databases. 5. Select the database to be deleted. 6. Click Finish to delete the database and remove all files on the disk associated with the selected database. Managing Database Templates Using DBCA DBCA stores the configuration definition of an Oracle database instance in an XML file, which is called a database template. You can use an existing database template for creating a new database and managing the configuration definition of the database. You can create a database template using DBCA.
34 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The default storage location for a database template is ORACLE_HOME/assistants/dbca/templates. DBCA uses two types of database templates: •
Seed Template – Contains database definition information, datafiles, and redo log files. DBCA makes copies of datafiles and redo log files present in the database definition file. These datafiles contain database schema, which speeds up the process of creating a new database. Seed templates have the .dbc extension. The datafiles and redo log files associated with the seed template are stored with the .djf extension. When you use a seed template, you can change the name of a database, configuration of initialization parameters, and locations of control and redo log files.
•
Non-seed Template – Contains only the database definition and does not store datafiles and redo log files. This template has the .dbt extension. When you use a non-seed template, you cannot change the name of a database, configuration of initialization parameters, or locations of control and redo log files.
Creating a Template Definition To create a template definition, select the Manage Templates option on the Operations screen and click Next. The Template Management screen is displayed. This screen contains three options to create a template definition: •
From an existing template – Creates a template definition from an existing template definition. This option enables you to review and modify settings, such as initialization parameter settings and datafiles storage characteristics, of an existing template. However, to create a template from an existing database, you must connect to the database to enable DBCA to obtain information about the database.
•
From an existing database (structure only) – Creates a template according to the structure of an existing database. This option is used to create a template for a database that has the same structure as another existing database but contains no data.
•
From an existing database (structure as well as data) – Creates a template according to the structure of an existing database. This template is used when you want to create an exact copy of an existing database.
After selecting an option to create a template definition, you can use DBCA to configure the template definition. DBCA presents a set of screens containing fields to configure the template definition. Deleting a Template Definition using DBCA You can delete an existing database template using DBCA. To delete an existing database template, select the Delete a database template option from the Template management screen. You can then select the template that you want to delete. When you delete the database template, DBCA removes the XML file of the deleted template from the database.
35 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Controlling a Database Scope •
Define how to handle parameter initialization files.
•
Identify the steps to start up and shut down an Oracle database.
•
Identify the type of information stored in the alert log file.
Focused Explanation Handling Parameter Initialization Files Each Oracle instance is configured according to the settings of a configuration file, called the parameter initialization file. This file stores the initialization parameters used when an Oracle database instance starts. Initialization parameter files are of two types: •
Parameter Files (PFILES) – Are text files that store initialization parameters.
•
Server Parameter Files (SPFILES) – Are binary files that store initialization parameters.
The default location for PFILES and SPFILES is $ORACLE_HOME\dbs on UNIX, and %ORACLE_HOME/database on Windows. You can specify a name for the initialization parameter file to use, when you issue a STARTUP command to start a database. At database startup, Oracle searches for the parameter initialization file to configure the Oracle database instance. If you do not specify the name of a parameter initialization file to use at startup, Oracle first searches for the spfileSID.ora file. The SID is the unique name of the database instance. If Oracle cannot locate this file, it searches for the spfile.ora file. Finally, if the server file is not found, Oracle searches for the initSID.ora parameter file. You can set the initialization parameters manually or use Enterprise Manager Database Control to modify the parameters. Startup Modes and Options of Oracle 10g Database An Oracle database can be started in one of several different modes, depending on the option used with the STARTUP command to start the instance. The following summarizes the STARTUP commands that can be used to start an Oracle database: •
STARTUP NOMOUNT – Starts a database instance without mounting the database. A database started in this mode reads the parameter file and initiates Oracle background processes and Oracle memory structures. In this mode, the background processes and Oracle memory structures do not establish communication with the disk structure of the database. If a database is started using the STARTUP NOMOUNT command, you can perform tasks such as running a script that creates a database.
36 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
STARTUP MOUNT – Starts a database instance and establishes communication between background processes and Oracle database memory structures. In this mode, you can perform all the tasks that can be performed if the database was started with the STARTUP NOMOUNT command, as well as some administrative tasks, such as recovery of a database, changing file locations, and enabling the archive log mode.
•
STARTUP OPEN – Starts a database instance and makes the database available to all users. This is the default startup mode, if you do not specify a startup mode option with the STARTUP command.
The following are some special STARTUP commands used to start an Oracle database: •
STARTUP FORCE – Performs a shutdown abort and then restarts the database instance. This STARTUP command is used if normal startup does not work. This startup mode option can be used with the STARTUP command for every database.
•
STARTUP RESTRICT – Starts a database instance and mounts the database in a restricted mode to provide access only to users who have the RESTRICTED SESSION privilege. When the database is started in this mode, you can perform various tasks, such as maintaining the database while the database is open, and importing and exporting the database. You can disable the restriction using the ALTER SYSTEM DISABLE RESTRICTED SESSION statement. Executing this statement allows every user to connect to the database.
Shutdown Options in Oracle 10g An Oracle database can be shut down using various methods. The following provides a summary of the SHUTDOWN commands you can use to shut down a database: •
SHUTDOWN NORMAL – Shuts down the database normally. Using this SHUTDOWN command ensures that no new connections are established after the command is issued. The database waits until all user connections are disconnected from the database. This option is the default SHUTDOWN command option.
•
SHUTDOWN TRANSACTIONAL – Shuts down the database normally, while allowing active transactions to complete. Using this SHUTDOWN command ensures that no new connections are established after the command is issued. If all active transactions are complete, all client connections are disconnected.
•
SHUTDOWN IMMEDIATE – Shuts down the database immediately. Using this SHUTDOWN command ensures that no new connections are established after the command is issued, rollbacks occur for all uncommitted transactions, and the Oracle database does not wait for clients to disconnect.
37 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
SHUTDOWN ABORT – Shuts down the database immediately by aborting the database. Using this SHUTDOWN command ensures that no new connections are established after the command is issued. In addition, all SQL statements are terminated, regardless of their state. With this shutdown mode, the Oracle database does not roll back the uncommitted transactions. This shutdown mode disconnects all the client connections immediately. When you shut down the Oracle database using this command, you would need to perform database recovery when you restart the database.
The shutdown commands SHUTDOWN NORMAL, SHUTDOWN TRANSACTIONAL, and SHUTDOWN IMMEDIATE do not require database recovery when you restart the database. These shutdowns are called clean shutdowns. Shutting Down Oracle Using Enterprise Manager Database Control To shut down Oracle 10g using Enterprise Manager Database Control, complete the following steps: 1. Invoke Enterprise Manager Database Control using the Web browser. 2. Type the user name and password in the User Name and Password text boxes and connect as a SYSDBA user. The Database:oracle page is displayed. 3. Click the Shutdown button under the general section of the Database:oracle page. The Startup/Shutdown: Specify Host and Target Database Credentials page is displayed.
38 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
You must provide the user name and password of the operating system and target database computer, as shown in Figure 2-5.
Figure 2-5: Startup/Shutdown: Specify Host and Target Database Credentials Page After authentication, the Startup/Shutdown: Confirmation page is displayed. The default shutdown option for the database is SHUTDOWN IMMEDIATE. Database Alert Log A database alert log is a file that contains information about certain activities, such as database startup and shutdown and internal Oracle errors.
39 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following are various events and actions stored in the alert log file: •
Startup and shutdown information
•
Information about administrative actions that have occurred, such as issuing ALTER SYSTEM and ALTER DATABASE statements
•
Information about Oracle internal errors that have occurred
•
Information about each initialization parameter having a different value from its default value
The location of the alert log file is specified by the BACKGROUND_DUMP_DEST initialization parameter.
40 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Creating and Controlling a Database: Oracle 10g Administration I Describe various components of Oracle Enterprise Manager. Identify the steps to create, configure, and drop a database, and manage database templates using DBCA. Discuss how to handle parameter initialization files. Identify the steps to start up and shut down an Oracle database. Discuss information stored in the alert log file.
41 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Managing Database Storage and Schema Objects: Oracle 10g Administration I
42 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Managing Database Storage Scope •
Define the components of database storage structures.
•
Describe how to create different types of tablespaces.
•
Understand how to manage extents and segment space in tablespaces. Describe how to modify and drop tablespaces.
•
Define the views available to obtain tablespace information.
Focused Explanation Database Storage Structure An Oracle database is divided into tablespaces, where each tablespace represents a group of logically related segments. A segment is a database entity, such as a table or index, which requires storage space. For example, a company’s database can contain various tablespaces, such as ACCOUNTS, and SALES. The ACCOUNTS tablespace can be used to group all segments of the Accounts department, and the SALES tablespace can be used to group all segments of the Sales department. The information of a tablespace is stored in one or more datafiles. A datafile contains extents, which represent the storage space of tablespaces. Note: An extent is composed of data blocks, which represent a fixed number of bytes of disk space. Creating and Managing Tablespaces When you create a database, Oracle creates the following three default tablespaces: •
SYSTEM: Contains data dictionary tables and system rollback segments.
•
SYSAUX: Contains schema objects, such as spatial data options, XMLDB or Intermedia.
•
TEMP: Helps to perform sort operations and stores transient data that persists only for the duration of a session.
To create additional tablespaces, you can use the CREATE DATABASE or CREATE TABLESPACE statement. You can specify the following options with these statements: •
The type of tablespace
•
The location of datafiles of the tablespace
•
Extent management options for the tablespace
•
Segment space management options for the tablespace
•
Whether or not a tablespace is a temporary tablespace
43 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Whether or not a tablespace is an undo tablespace
Specifying the Type of the Tablespace Oracle 10g provides two options to specify the type of a tablespace. A tablespace can be a bigfile tablespace or a smallfile tablespace. A bigfile tablespace contains a single, but very large, datafile, which can consist of a maximum of 232 data blocks. For example, you can use bigfile tablespaces for creating tablespaces in a database that contains thousands of read/write datafiles and takes a long time for updating these datafiles. The syntax for creating a bigfile tablespace is: CREATE BIGFILE TABLESPACE tablespace_name DATAFILE location SIZE sizeoption; In this syntax, tablespace_name refers to the name of the tablespace, location refers to the location of the datafile, and sizeoption specifies the datafile size. A smallfile tablespace contains more than one datafile. Each datafile can consist of up to 222 data blocks. The SYSTEM and SYSAUX tablespaces are created as smallfile tablespaces. The syntax for creating a smallfile tablespace is: CREATE SMALLFILE TABLESPACE tablespace_name DATAFILE location SIZE sizeoption; In this syntax, tablespace_name refers to the name of the tablespace, location refers to the location of the datafile, and sizeoption specifies the datafile size. Note: If you do not specify an option for the type of tablespace with the CREATE TABLESPACE statement, then a smallfile tablespace is created. Specifying the Location of Datafiles You must specify the location of datafiles either implicitly using Oracle-Managed Files (OMF) or explicitly when creating a tablespace. The following is an example of explicitly specifying the location of datafiles when creating a tablespace: CREATE SMALLFILE TABLESPACE rec2005mar DATAFILE ‘/ORADATA/ORCL1/rec2005mar.dbf’ SIZE 25G; Note: OMF is a feature of an Oracle database that helps you manage datafiles. It allows Oracle to manage these files for you, and reduces the amount of administrative effort required. If you are using OMF, you do not need to specify the location of the datafiles. To enable OMF, you must set the DB_CREATE_FILE_DEST initialization parameter to the directory in which you want to store your datafiles and temporary files.
44 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following is an example of setting this parameter: ALTER SYSTEM SET DB_CREATE_FILE_DEST='/u01/oradata/orcl10' SCOPE=BOTH; After the OMF feature is enabled, you do not need to include the DATAFILE clause in the CREATE TABLESPACE statement. The following is an example of how to create a tablespace when the OMF feature is enabled: CREATE TABLESPACE sales_data; This statement creates the sales_data tablespace. The datafiles of this tablespace are stored at the location specified by the DB_CREATE_FILE_DEST parameter. Managing Extents Oracle provides two methods that you can use to manage extents in a tablespace. These are: •
Dictionary extent management
•
Local extent management
Using the dictionary extent management method, the extent management information of a tablespace is stored in data dictionary tables. This extent management technique keeps a record of used and free extents in the data dictionary tables UET$ and FET$, respectively. With this method, whenever an extent is allocated or is free, the information is updated in corresponding data dictionary tables. A tablespace that uses dictionary extent management is called a dictionary-managed tablespace. The following is an example of creating a dictionary-managed tablespace: CREATE TABLESPACE sales_data DATAFILE '/ORADATA/ORCL1/salesdata2005.dbf' SIZE 100M EXTENT MANAGEMENT DICTIONARY; This statement creates a dictionary-managed tablespace sales_data, with datafiles of 100 MB stored at the specified location. Using the local extent management method, the extent management information of a tablespace is stored in the same tablespace in each datafile. This extent management information is stored using bitmaps. Each bit of these bitmaps corresponds to a database block or a group of database blocks. Whenever an extent in a tablespace is allocated or is free, the status of bits corresponding to the data blocks of the extent is changed. A tablespace that uses local extent management is called a locally-managed tablespace. The local extent management method provides two options to specify how extents are allocated to locally-managed tablespaces: •
UNIFORM – Ensures that all extents allocated or deallocated from tablespaces are of a specified size. When you use this option, the default size of an extent is 1 MB. The UNIFORM option does not apply for undo tablespaces and is the default option for temporary tablespaces.
45 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
AUTOALLOCATE – Specifies varying size of extents for each segment. When you use this option, Oracle manages the size of extents itself. For example, when you use the AUTOALLOCATE option on the Windows platform with data blocks of size 8 KB, each segment allocates the first 16 extents of size 64 KB, the next 63 extents of size 1 MB, and then allocates the next 120 extents of size 8 MB and so on. This process allows small segments to remain small and large segments to expand without increasing too many extents.
The following is an example to create a locally-managed tablespace named sales2005data with the AUTOALLOCATE option enabled: CREATE TABLESPACE sales2005data DATAFILE '/ORADATA/ORCL1/ sales2005data.dbf' size 25G EXTENT MANAGEMENT LOCAL AUTOALLOCATE; Note: You can change extent management of a tablespace from dictionary-managed to locally-managed, and vice versa, using the DBMS_SPACE_ADMIN package. However, you cannot use this package to change the extent management of the SYSTEM tablespace or temporary tablespaces from locallymanaged to dictionary-managed. Specifying Segment Space Management Segment space management is applicable only to locally-managed tablespaces. You can specify the MANUAL or AUTO option with the CREATE TABLESPACE statement to manage segments of a locallymanaged tablespace. The MANUAL segment management option identifies available data blocks using free block lists. It uses two parameters, the PCT_FREE and PCT_USED parameters. When you use the MANUAL segment management option, the Oracle database calculates the space available in a data block after every insert, delete, and update operation. If the space available in the data block is less than the value of the PCT_FREE parameter, the data block is marked as used and is removed from the free data block list. If the space available is less than the value of the PCT_USED parameter, the database block is marked as free and placed in free data block list. By default, a locally-managed tablespace uses the MANUAL segment storage option. To explicitly specify the MANUAL segment option, you can use the SEGMENT SPACE MANAGEMENT clause with the CREATE TABLESPACE statement. The following example shows how to create a locally-managed tablespace with the MANUAL segment space management option: CREATE TABLESPACE sales2005data DATAFILE '/ORADATA/ORCL1/ sales2005data.dbf' SIZE 25G EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT MANUAL; The AUTO space management option uses bitmaps to maintain the record of free data blocks. This space management option does not use the PCT_FREE and PCT_USED parameters. You cannot use the AUTO space management option for the SYSTEM tablespace or temporary tablespaces.
46 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following example shows how to create a locally-managed tablespace named sales2005data with the AUTO segment space management option: CREATE TABLESPACE sales2005data DATAFILE '/ORADATA/ORCL1/ sales2005data.dbf' SIZE 25G EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT AUTO; Specifying a Tablespace as a Temporary Tablespace A temporary tablespace represents a logical group of temporary database segments. These temporary database segments are commonly created during sorting operations, such as when a query with an ORDER BY or GROUP BY clause is executed or when an index is created using the CREATE INDEX statement. A temporary tablespace uses tempfiles instead of datafiles for storing information of temporary segments. When temporary segments are created, the Oracle database allocates storage space for tempfiles. You can create temporary tablespaces in two ways: •
Using the DEFAULT TEMPORARY TABLESPACE clause with CREATE DATABASE statement
•
Using the CREATE TEMPORARY TABLESPACE statement after creating the database
The following is an example of how to create a temporary tablespace named temp_data: CREATE TEMPORARY TABLESPACE temp_data TEMPFILE 'D:\ORACLE\ORADATA\ORCL\temp_data01.dbf' SIZE 2G; Specifying a Tablespace as an Undo Tablespace An undo tablespace represents a logical group of undo segments. An undo segment is a database entity that stores information to roll back a database transaction or other uncommitted changes to the data. To create an undo tablespace, you can either set the value of the UNDO_MANAGEMENT initialization parameter to AUTO or use the CREATE UNDO TABLESPACE statement. The following is an example to create an undo tablespace named undotbs by using the CREATE UNDO TABLESPACE statement: CREATE UNDO TABLESPACE undotbs DATAFILE '/ORADATA/ORCL1/sales2005data.dbf'
SIZE 2G;
Dropping a Tablespace You use the DROP TABLESPACE statement to drop a tablespace. You can use the optional INCLUDING CONTENTS clause to remove the segments of the tablespace recursively. The following is an example to drop a tablespace: DROP TABLESPACE sales2005data INCLUDING CONTENTS; The datafiles of a tablespace are not removed when a tablespace is dropped. To drop a tablespace along with its datafiles, use the following statement syntax: DROP TABLESPACE tablespace_name INCLUDING CONTENTS AND DATAFILES;
47 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Modifying a Tablespace You can modify a tablespace using the ALTER TABLESPACE statement. The operations that you can perform using this statement are: •
•
•
Renaming a tablespace – Use the ALTER TABLESPACE tablespace_name RENAME TO new_tablespace_name statement to rename a tablespace. In this statement: o
tablespace_name – Refers to the name of the tablespace.
o
new_tablespace_name – Refers to the new name for the tablespace.
Adding a datafile to a tablespace – Use the ALTER TABLESPACE tablespace_name ADD DATAFILE 'datafile_nameandlocation' SIZE datafile_size statement to add a datafile in a tablespace. In this statement: o
tablespace_name – Refers to the name of the tablespace to which the datafile will be added.
o
datafile_nameandlocation – Refers to the name and location of the datafile.
o
datafile_size – Refers to the size of the datafile.
Taking a tablespace offline or online – Use the ALTER TABLESPACE tablespace_name OFFLINE statement to take a tablespace offline and the ALTER TABLESPACE tablespace_name ONLINE statement to make the tablespace online. The tablespace_name refers to the name of the tablespace. Note: You cannot make a backup of a tablespace when it is online.
•
Making a tablespace read-only – Use the ALTER TABLESPACE tablespace_name READ ONLY statement to make a tablespace read-only. To change to a read-only tablespace so that it can be written to, use the ALTER TABLESPACE tablespace_name READ WRITE statement.
•
Putting a tablespace in backup mode – Use the ALTER TABLESPACE tablespace_name BEGIN BACKUP statement to put a tablespace in backup mode. Use the ALTER TABLESPACE tablespace_name END BACKUP statement to take a tablespace out of backup mode.
Obtaining Tablespace Information Oracle provides several views that provide information about tablespaces. These are: •
DBA_TABLESPACES – Contains one row for each tablespace in the database. This view contains information about the tablespace block size, status of the tablespace, contents of the tablespace, the type of extent management, the segment space management, and whether the tablespace is a bigfile tablespace or a smallfile tablespace.
•
DBA_DATA_FILES – Contains information about datafiles of each tablespace.
48 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
DBA_TEMP_FILES – Contains information about tempfiles of tablespaces.
•
V$TABLESPACE – Contains the same information that the DBA_TABLESPACE view provides and additional information, such as whether or not the tablespace participates in database flash backup operations.
49 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Working with Schema Objects Scope •
Describe the various forms of data types.
•
Know how to create and manage tables and specify constraints.
•
Identify the statements to create and drop indexes.
•
Understand how to create and drop views
•
Understand how to create, alter, and drop sequences.
Focused Explanation A schema represents a collection of database objects that are owned by a specific database user. A schema contains segment objects, such as tables and indexes, and non-segment objects, such as constraints and views. Describing Data Types In Oracle, data types are categorized as either Character, Numeric, Datetime, LOB, ROWID, or Binary data types. Character data types store alphanumeric data in the database character set or the Unicode character set. The database character set specifies the language that can be represented in a database and is specified when creating a database. The following are the various database character data types: •
CHAR(size [byte|char]), NCHAR(size) – Specifies a fixed-width space for storing characters. By default, the size of this fixed-width space is specified in bytes. The NCHAR data type is a variation of the CHAR data type. NCHAR uses the Unicode character set and the size of this data type is specified in characters.
•
VARCHAR(size [byte|char]), VARCHAR2(size [byte|char]), NVARCHAR2(size) – Allocates a variable-width space for storing characters. By default, the size is specified in bytes, if you do not specify the char keyword.
•
LONG – Stores variable-length alphanumeric data up to a size of 2 GB. A table can contain a maximum of one LONG data type column.
An Oracle database provides numeric data types for storing positive, negative, fixed, and floating-point numbers. The numeric data types available in Oracle are: •
NUMBER [(precision[, scale])] – Stores positive, zero, and negative numbers. The precision parameter specifies the total number of digits. The default value of precision is 38. The scale parameter specifies the number of the digits to the right of the decimal point. The default value of scale is zero.
50 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
BINARY_FLOAT, BINARY_DOUBLE – Stores single-precision and double-precision floating-point values, respectively.
Oracle 10g provides several datetime data types, such as DATE,INTERVAL YEAR TO MONTH, INTERVAL DAY TO SECOND, and TIMESTAMP, to store date, time, and time periods. LOB data types are used to store text, image, video, audio, and spatial data. Each LOB data type can store up to 231 –1 data blocks. The different LOB data types are: •
CLOB – Stores variable-length character data.
•
NCLOB – Stores variable-length character data using a Unicode character set.
•
BLOB – Stores binary variable-length data in the database.
•
BFILE – Stores binary variable-length data external to the database on operating system files.
The ROWID data type represents an address that identifies each row in a table. This data type is used for a column of your table that stores pointers to rows in other tables. Creating Tables Tables are the database segments that organize data in the form of rows and columns. You can create a table in an Oracle database using the following syntax: CREATE TABLE table_name ( column1 datatype (size), column2 datatype (size), ..., columnn datatype (size) ); •
table_name: Refers to the name of the table to be created.
•
columnn: Refers to a name for a column in the table being created.
•
datatype (size): Refers to the corresponding data type and size of the specified column.
You should consider the following guidelines for naming tables: •
Must begin with a letter.
•
May be from 1 to 30 characters long.
•
May include letters, numbers, and the _, #, and $ symbols.
•
Cannot be a SQL reserved word, such as NUMBER or INDEX.
•
Is not case-sensitive.
•
Must not be the same as any other database object in the same schema.
51 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
You can also create tables using queries that select rows from other tables and insert these rows into the table to be created. The syntax for creating a table using a query is: CREATE TABLE table_name NOLOGGING COMPRESS TABLESPACE tablespace_name AS SELECT * FROM source_table_name; The description of various parameters in this statement is: •
table_name – Refers to the name of the table to be created.
•
tablespace_name – Specifies the name of the tablespace in which the table will be created.
•
source_table_name – Specifies the name of the source table used for the SELECT statement.
•
NOLOGGING – Disables the logging of transactions for the table.
•
COMPRESS – Specifies that data added to the table will use data compression.
Creating a Temporary Table A temporary table stores transitory values which are visible only to the session that inserted data into the temporary table. To create a temporary table, use the following syntax: CREATE GLOBAL TEMPORARY TABLE table_name ( column1 datatype (size), column2 datatype (size), ..., columnn datatype (size) ) ON COMMIT DELETE ROWS; •
table_name: Refers to the name of the temporary table to be created.
•
columnn: Refers to a name for a column in the temporary table being created.
•
datatype (size): Refers to the corresponding data type and size of the specified column.
Specifying Default Values for a Database Column You can specify a default value for a column in your table using the DEFAULT clause. The default value is inserted into the column if you do not explicitly insert a value in that column when inserting a row into the table.
52 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following is an example to create a table with columns that have default values: CREATE TABLE log_info ( log_id number, username VARCHAR2(64) DEFAULT MYUSER, time_of_log TIMESTAMP DEFAULT SYSTIMESTAMP, info VARCHAR2(200) ) TABLESPACE users; You can also use the ALTER TABLE statement to specify default values after a table has been created. The following is an example to specify the default value for a column after creating the table: ALTER TABLE log_info MODIFY username VARCHAR2(64) DEFAULT MYUSER; Renaming a Table You can change the name of your table using the following syntax: RENAME table_name TO new_table_name; •
table_name: Refers to the name of the table to be renamed.
•
new_table_name: Specifies the new name for the table.
You can also use the ALTER TABLE statement to rename your table. The following is the syntax to rename a table using the ALTER TABLE statement: ALTER TABLE table_name RENAME TO new_table_name; Adding and Dropping Columns in a Table You use the ALTER TABLE statement to add columns to or drop columns from a table. The syntax for adding columns to a table is: ALTER TABLE table_name ADD new_column_name datatype (size); •
table_name: Refers to the name of the table in which the column is to be added.
•
new_column_name: Specifies the name of the column to be added.
•
datatype: Specifies the data type of the new column.
•
size: Specifies the size of the new column, if a size is applicable for the data type specified.
53 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The syntax for removing columns from a table is: ALTER TABLE table_name DROP COLUMN column_name; •
table_name: Specifies the name of the table.
•
column_name: Specifies the name of the column to be removed.
Specifying Constraints on a Table Constraints provide rules to limit the acceptable data values for one or more columns in a table. The following are the constraints that can be defined on a table: •
NOT NULL: Specifies that a column in a table cannot contain null values.
•
UNIQUE: Specifies that each value in a column must be unique and a null value is allowed.
•
PRIMARY KEY: Specifies that each value in a column must be unique and not null.
•
FOREIGN KEY: Specifies that the value in a foreign key column can be either equal to a value in the primary key column or can be null.
•
CHECK: Specifies that a column value or set of column values must meet a specific condition.
Working with Indexes Indexes are segments that are defined on a table to improve data retrieval performance. Indexes provide direct access to a table when searching data, instead of performing a default full table scan. The following are the criteria by which indexes are categorized: •
The number of columns used to create an index
•
Whether or not the index column contains unique values
•
Whether an index is partitioned or non-partitioned
•
Whether the index is created as a B-tree or a bitmap index
If an index is created on a single column, the index is called a simple index. If the index is created on more than one column of the table, the index is called a composite index. You can specify a maximum of 32 columns when creating a composite index. B-tree indexes store the data in a tree structure. The root of the tree contains pointers to the node of the next level in the index. Depending on the value for which you search, the root node points you to one of its next level nodes. The node on the next level root contains pointers to nodes of its next level. Again, according to the search value, you get the pointer of one of the next level nodes.
54 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The search continues like this until the search process reaches the highest level of the tree, called a leaf node. The leaf nodes contain the value of indexed columns and ROWID of rows that store those column values. The leaf nodes are connected to its adjacent nodes, which help perform the search up and down through a range of entries in the index. A bitmap index creates entries with the following information: •
Distinct values in an indexed table
•
Start and stop ROWIDs of the indexed table
•
A binary string, called a bitmap, that contains number of bits equal to the number of distinct values in indexed table
When a value to be searched matches with a distinct value, the bit corresponding to this distinct value is marked as one. This indexed structure improves the performance of the search on the indexed table. Creating and Dropping Indexes You use the CREATE INDEX statement to create a B-tree index on one or more columns of a table. The syntax for creating a B-tree index is: CREATE INDEX index_name ON table_name (column1, column2 ,...,columnn) TABLESPACE tablespace_name; The various parameters in this statement are •
index_name: Refers to the name of the index to be created.
•
table_name: Refers to the name of the table on which the index will be created.
•
columnn: Refers to the columns on which the index will be created.
•
tablespace_name: Refers to the tablespace in which the index will be stored.
The syntax for creating bitmap indexes is: CREATE BITMAP INDEX index_name ON table_name (column1, column2,...,columnn); The various parameters in this statement are: •
index_name: Refers to the name of the bitmap index to be created.
•
table_name: Refers to the name of the table on which the index will be created.
•
columnn: Refers to the columns on which the bitmap index will be created.
55 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The syntax to remove an index from the database is: DROP INDEX index_name; Working with Views Views are logical tables based on one or more tables in a database. Tables on which views are based are called base tables. You can create a view on a single table or with a query that incorporates multiple base tables. You can use the views to restrict access to a table or reduce the complexity of writing queries by being able to reference multiple joined tables with a single view name. You use the CREATE VIEW statement to create a view. For example, to create a view named emp_view based on the emp and dept tables, you could specify the following statement: CREATE OR REPLACE VIEW emp_view AS SELECT EmpNo, Ename, emp.DeptNo, Dname FROM emp, dept WHERE emp.DeptNo=dept.DeptNo; In this statement, the emp_view view incorporates data from the emp and dept tables. The OR REPLACE clause instructs the database to replace the view definition if it already exists in the database. You can also delete a view from the database by using DROP VIEW statement. For example, to delete the emp_view view from the database, you can specify the following statement: DROP VIEW emp_view; Working with Sequences Sequences are schema objects that help to provide unique sequential values by generating unique integers. You can create a new sequence in Oracle 10g using the CREATE SEQUENCE statement. When creating a new sequence using the CREATE SEQUENCE statement, you must specify a name for the sequence. You can also use other clauses to further define the sequence. The following are the commonly used clauses of the CREATE SEQUENCE statement: •
START WITH – Specifies an initial value for the sequence. For an ascending sequence, the default value of the START WITH clause is the minimum value, which is specified by the MINVALUE clause, of the ascending sequence. For a descending sequence, the default value of the START WITH clause is the maximum value, which is specified by the MAXVALUE clause, of the descending sequence.
•
INCREMENT BY – Specifies how to generate the sequence numbers after the first number. The default value of the INCREMENT BY clause is 1. You can specify any nonzero integer less than 29 digits as the value for the INCREMENT BY clause. When the INCREMENT BY clause has a negative value, then a descending sequence with progressively lower numbers is generated. An INCREMENT BY clause with a positive value generates an ascending sequence with progressively higher numbers.
56 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
MAXVALUE – Specifies the highest number that a sequence can generate. The default value of the MAXVALUE clause is the NOMAXVALUE constant. The NOMAXVALUE constant evaluates to 1027 for an ascending sequence and −1 for a descending sequence.
•
MINVALUE – Specifies the lowest value that a sequence can generate. The default value of the MINVALUE clause is the NOMINVALUE constant. The NOMINVALUE constant evaluates to −1026 for an ascending sequence and −1 for a descending sequence.
•
CACHE – Specifies the number of values that can be preallocated and held in memory. The default value for the CACHE clause is 20. You can specify any value ranging from 2 to the number returned from the formula (CEIL(MAXVALUE –MINVALUE)) / ABS(INCREMENT BY).
For example, the following example shows how to create an empnum sequence that begins with a sequence value of 5500 and is incremented by one each time a new value is retrieved: CREATE SEQUENCE empnum INCREMENT BY 1 START WITH 5500; You generate the next sequence number by referencing the NEXTVAL pseudocolumn. The following statement shows an example of retrieving the next sequence number for the empnum sequence: SELECT empnum.NEXTVAL FROM dual; You can modify the INCREMENT BY, MAXVALUE, MINVALUE, and CACHE clauses of a sequence using the ALTER SEQUENCE statement. The following is an example of modifying the empnum sequence so that it decrements by one each time a new value is retrieved: ALTER SEQUENCE empnum INCREMENT BY –1; You can reset the next value that a sequence generates by dropping the sequence and then re-creating the sequence. The following example drops the empnum sequence: DROP SEQUENCE empnum;
57 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Managing Database Storage and Schema Objects: Oracle 10g Administration I Describe database storage structures. Describe how to create different types of tablespaces. Describe how to manage extents and segment space in tablespaces. Describe how to modify and drop tablespaces. Obtain tablespace information. Describe data types. Describe how to create and manage tables and specify constraints. Describe how to create and drop indexes. Describe how to create and drop views. Describe how to create, alter and drop sequences.
58 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Managing Data and Programming with PL/SQL: Oracle 10g Administration I
59 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Using Database Interfaces Scope •
Define database interfaces.
•
Learn how to query tables using SQL statements.
•
Learn how to create tables using SQL statements.
Focused Explanation Describing Database Interfaces A database interface is an end-user interface used for data manipulation, data definition, and the definition of access rights for a database. In Oracle 10g, you can use two command-line tools, SQL*Plus and iSQL*Plus, to issue SQL commands to the database. Using SQL*Plus to Access a Database You need the following configuration on your computer to access an Oracle database using SQL*Plus: •
SQL*Plus client software on your local computer or SQL*Plus accessible on the host server through a remote logon
•
A valid database user name and password
•
Oracle Net connection string of the database to which you want to connect
After you connect to the database using SQL*Plus, you can issue SQL commands at the SQL prompt. The following statement shows how to access the EMPLOYEE table using a SQL statement: SQL> SELECT * from EMPLOYEE; The SELECT statement ends with a semicolon (;). All SQL statements in SQL*Plus end with either a semicolon or a forward slash (/). Note: When a SQL statement ends with a forward slash, only the forward slash should be the last line of the statement. Using iSQL*Plus to Access a Database You need the following configuration on your system to access an Oracle database using iSQL*Plus: •
Web browser
•
URL address of the host server running the iSQL*Plus Web site
•
Valid database user name and password
60 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Oracle Net connection string of the database to which you want to connect
The iSQL*Plus interface consists of two windows. The first window is used for entering SQL statements, and the second window displays the output of these statements. Similar to SQL*Plus, each SQL statement in the iSQL*Plus interface can either end with a semicolon or a forward slash (/). Using SQL Statements to Query and Create Tables You can query the tables in a database using the SELECT statement. The SELECT statement retrieves data from a table. The syntax of the SELECT statement in Oracle 10g is: SELECT [ALL|DISTINCT] select_list FROM table_name [WHERE search_condition]; To create tables in a database, you can use Data Definition Language (DDL) statements. The CREATE statement creates a table in a database. The syntax of the CREATE statement is: CREATE TABLE table_name (column1 data_type_column1, column2 data_type_column2,... columnn data_type_columnn);
61 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Manipulating Data using Data Manipulation Language Statements Scope •
Describe data manipulation using INSERT, UPDATE, and DELETE statements.
Focused Explanation Data Manipulation Language (DML) statements are used to manipulate data in the database. There are three DML statements, INSERT, UPDATE, and DELETE. Using the INSERT Statement You can use the INSERT statement to add rows of data with specific values to a table and to copy the rows from an existing table into a new table using a subquery. The INSERT statement can also be used for inserting rows into a single table or into multiple tables. The following is the syntax to use the INSERT statement for adding records to a single table: INSERT INTO table_name[(column1,column2,column3...columnn)] VALUES(value1,value2,...valuen); You can also insert records into a view, which inserts data into the underlying base tables, if the view does not contain the following values: •
A DISTINCT operator
•
A set operator, such as UNION or MINUS
•
An aggregate function, such as SUM, COUNT, or AVG
•
A GROUP BY, ORDER BY, or CONNECT BY clause
•
A subquery in the SELECT list
For example, you can use the following INSERT statement to insert records into the employees table: SQL> INSERT INTO employees (employee_id, employee_name, employee_dept, sal) VALUES (222, ‘Jorge’, ‘Mkt.’, 2000); Note: In the INSERT statement, if you insert values in all the columns of a table, you do not need to include the name of the columns in which you want to insert values. You can also use the INSERT statement to copy records from one table to another. An example of copying one or more rows from a table to another table is: SQL> INSERT INTO regions (region_id, region_name) 2 VALUES (SELECT region_seq.NEXTVAL, terr_name 3 FROM territories@home_office WHERE class = ‘R’);
62 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The number and data types of the values inserted in the VALUES list must match the number and data types in the column list. The database implicitly converts the data type of each value to be copied from the source table to the data type of the target table. Inserting Data into Multiple Tables Oracle also supports a multi-table INSERT statement to simultaneously insert records into multiple tables. You can use this statement to make a single pass through the source data and load the data into more than one table. You can achieve faster throughput by reducing the number of passes through the source data. For example, an insurance company has both property and casualty policies stored in a table named policies. In the data mart, these policies are represented in two separate tables, property_premium_fact and casuality_premium_fact. Here, you can use a multi-table INSERT to add the records to database tables more efficiently than using two separate INSERT statements. The following statements show how to use the multi-table INSERT statement: SQL>INSERT FIRST 2 WHEN policy_type = ‘P’ THEN 3 INTO property_premium_fact (policy_id, policy_nbr, premium_amt) 4 VALUES (property_premium_seq.nextval, policy_number, gross_premium) 5 WHEN policy_type = ‘C’ THEN 6 INTO casuality_premium_fact (policy_id, policy_nbr, premium_amt) 7 VALUES (property_premium_seq.nextval, policy_number, gross_premium) 8 SELECT policy_number, gross_premium, policy_type 9 FROM policies 10 WHERE policy_date >= TRUNC(SYSDATE,’MM’) – TO_YMINTERVAL(’00-01’); In this statement, records are retrieved from the policies table and depending on the value of the policy_type column, retrieved data is inserted into either the property_premium_fact table or the casuality_premium_fact table. When using a multi-table INSERT statement instead of two separate INSERT statements, the code makes a single pass through the policies table, instead of two different passes and loads the data faster. Using the UPDATE Statement The UPDATE statement is used to change the existing records in a table. The syntax of the UPDATE statement is: UPDATE table_name SET column_name=value; The SET clause can be a list of columns, with their corresponding values, separated by commas.
63 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following example updates the phone number and fax number of a customer whose customer ID is 302 and sets the quantity based on the customer’s orders in the order_details table: SQL> UPDATE order_table r SET phone = ‘8277588800’, 2 fax = ‘6789698999’, 3 qty = (SELECT SUM(d.qty) 4 FROM order_details d 5 WHERE d.customer_id = r.customer_id) 6 WHERE r.customer_id = 302; These statements update the values in the phone, fax, and qty columns of the order_table table. The value assigned to the qty column is derived from a subquery. This subquery returns the sum of the values in the qty column of the order_details table, where the value in the customer_id column of the order_details column is equal to the value in the customer_id column of the order_table table. Using the DELETE Statement The DELETE statement is used to remove records from a table. The syntax for the DELETE statement is: DELETE FROM table_name WHERE column_name=value; You can delete only those rows that satisfy a particular condition, by specifying the condition in the WHERE clause of the DELETE statement. For example, you can use the following DELETE statement to remove the customer orders from the orders table for specified values of the state and order_date fields: SQL> DELETE FROM orders 2 WHERE state IN (‘TX’, ‘NY’, ‘IL’) 3 AND order_date < TRUNC(SYSDATE) – 90; This statement deletes those rows from the orders table for which the state column contains the TX, NY, or IL value and the order_date column contains a value older than 90 days from the current date. The following example removes rows from the line_detail table that have duplicate values of the detail_id column in the detail table: SQL> DELETE FROM line_detail 2 WHERE rowid NOT IN (SELECT MAX(rowid) 3 FROM detail 4 GROUP BY detail_id); When the WHERE clause is not used, all the records from the table are deleted. You can also use the TRUNCATE TABLE statement to delete all the records from a table. However, you cannot roll back the TRUNCATE TABLE statement.
64 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Using Data Pump and SQL*Loader Scope •
Define Data Pump and how to use it for import and export of data.
•
Describe how to work with SQL*Loader and create directory objects.
Focused Explanation Exporting Data using Data Pump Export The Data Pump is a mechanism for transferring data or metadata from one database to another database. The Data Pump uses direct path loading and unloading technologies. These technologies use direct-path APIs for providing the data to be loaded and unloaded on the Oracle server. The Data Pump runs on the server-side, unlike the old version of import and export programs, which operate on the clientside of a database. You can use the Data Pump export to call a DBMS_DATAPUMP package by running the expdp program or by running a PL/SQL program. You can also run Data Pump exports using a graphical user interface provided by Enterprise Manager Database Control. Performing Data Pump Export Jobs Using the expdp Program To perform the Data Pump export jobs using the expdp program, you need to create directory objects to store files, such as dump, log, and SQL files. Creating Directory Objects Directory objects represent the location of a directory on the database server. These objects can be used with various database features, such as bigfile tablespaces, external tables, utl_file, and Data Pump. The following statements show how to create data directories using the CREATE DIRECTORY statement in UNIX: CREATE DIRECTORY dump_file AS ‘/oracle/data_pump/dumps’; CREATE DIRECTORY log_dir AS ‘/oracle/data_pump/logs’; When creating a data directory in Windows, you use the following statement: CREATE DIRECTORY dpump_dir AS ‘c:\datapumps’; Using Data Pump Export Modes The following are various modes in which you can perform data pump export jobs using the expdp program: •
Full Export mode – Used to export a complete database.
•
Schema Export mode – Used to export the database objects that belong to a specified schema.
65 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Table Export mode – Used to export only specified tables, partitions of tables, and database objects that are dependent on these tables.
•
Tablespace Export mode – Used to export the tables contained in a specified set of tablespaces.
•
Transportable Tablespace Export mode – Used to export only the metadata for tables contained in a specified set of tablespaces and database objects that are dependent on these tables.
Using the Full Export Mode You must be granted the EXP_FULL_DATABASE role to perform a full database export. For example, the following command is used for performing a full database export to files in the chap3a and chap3b directories: expdp system / secret full=Y dumpfile=chap3a:fulla%U.dmp, chap3b:fullb%U.dmp filesize=2G parallel=2 logfile=chap3:full.log These parameters instruct the Data Pump program to connect to the database using the SYSTEM user name and SECRET password. The full=Y parameter enables the Data Pump to perform a database mode export. The Data Pump saves a series of dump files alternating between the chap3a and chap3b directories. The %U parameter facilitates the Data Pump to insert a sequential number into each filename. Each file contains 2 GB of data. The log file full.log is saved in the chap3 directory. Using the Schema Export Mode A schema mode export is performed by omitting the full=Y parameter and including a schemas=schema_list parameter in the expdp program parameter list. The schema list is a commadelimited list of schemas. You can export your own schema by omitting both the full and the schemas parameters. To export another user’s schema, you must have been granted the EXP_FULL_DATABASE role. The command to export the hr schema is: expdp hr/hr dumpfile=chap3:hr.dmp logfile=chap3:hr.out The dumpfile and logfile parameters work in the same way in all export modes. A colon and the file name follow the database directory object. Depending on operating system, the names of the files used can be case-sensitive. For example, on the Windows operating system, the names of files are not casesensitive. However on the UNIX platform, the names are case-sensitive. Using the Table Export Mode A table mode export is performed by including a tables=table_list parameter and omitting the full and schemas parameters. The table_list is a comma-delimited list of tables to be exported. These tables can be specified with the owner using dot notation, such as HR.EMPLOYEES. For example, the command to export the metadata for hr owned jobs and job_history tables is: expdp hr/hr dumpfile=char3:job_tabs.dmp nologfile=y content=metadata_only tables=jobs,job_history
66 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The nologfile=y parameter enables the Data Pump not to write the log file to disk. The content=metadata_only parameter enables the Data Pump to export only the metadata and not the data in the table. Using the Tablespace Export Mode To perform a tablespace mode export, the database user must have been granted the EXP_FULL_DATABASE role. You can use the tablespaces=tablespace_list parameter to specify a comma-delimited list of the tablespaces to be exported. For example, the command to export all the objects from the tablespaces USERS and USERS1 is: expdp system /password dumpfile=chap3:users_ts.dmp logfile=chap3:users_ts.out tablespaces=USERS,USERS1 The help=y parameter enables you to see the full list of parameters used with the expdp program. You can also place all the parameters in a file and then execute the expdp program to read these parameters using the parfile=directory:filename parameter. The directory portion of the parameter refers to a database directory object and the filename portion of the parameter refers to the name of the file that contains the parameters to use for the export. Using Transportable Tablespace Export Mode You must have been granted the EXP_FULL_DATABASE role to perform a transportable tablespace mode export. This mode allows you to export metadata information from one database to another. For example, the command to export metadata information using the transportable tablespace mode is: expdp system / password directory=dpump_dir1 dumpfile=ttbs.dmp transport_tablespaces=ttbs transport_full_check=y logfile=ttbs.log The transport_full_check=y parameter verifies storage segments of all tables. Data Pump Export Parameters Data Pump export parameters are the parameters required to perform data export jobs. Table 4-1 describes the Data Pump export parameters.
Parameter full=y schemas=schema_list tables=table_list tablespaces=tablespace_list content=content_option network_link=db_link
Description Specifies a database export mode. Specifies a schema mode export where schema_list is a list of schemas to be exported. Specifies a table mode export where table_list is a list of tables to be exported. Specifies a tablespace mode export where tablespace_list is a list of tablespaces to be exported. Specifies whether data, metadata, or both are exported. Specifies that a remote database used is accessed through the database link db_link and is used as the export source.
67 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Parameter dumpfile=dir:file filesize=size_limit logfile=dir:file directory=dir
Description Specifies the dump file location and name. Specifies the maximum size of the dump file. Specifies the log file location and name. Specifies the file location to be used for both the dump file and the log file. Specifies that no log file should be written. Specifies a name for the import job. Specifies the maximum number of active threads or processes operating for the import. Specifies the file location and name of the parameter file that the Data Pump export uses.
nologfile=y job_name=identifier parallel=degree parfile=dir:file
Table 4-1: The Data Pump Export Parameters Performing Data Pump Export Jobs Using the DBMS_DATAPUMP Package You can use the DBMS_DATAPUMP PL/SQL package to export data using the Data Pump. The DBMS_DATAPUMP PL/SQL package provides greater function and control and also schedules the Data Pump export jobs for a database scheduler. The series of actions for a PL/SQL-initiated Data Pump session are as follows: •
Obtain a handle to a Data Pump session.
•
Define the dump and log file.
•
Define a filter condition.
•
Launch the Data Pump session.
•
Disconnect from the session.
Importing Data Using Data Pump Import Export extracts data and metadata from the database, and import loads this extracted data into the same or a different database using the Data Pump. Loading the database enables you to copy tables, from one schema to another or map a tablespace from one database to another. You can use the Data Pump import to call a DBMS_DATAPUMP package by running the impdp program or by running a PL/SQL program. Performing Data Pump Import Jobs Using the impdp Program The Data Pump import program, impdp, operates in various modes, namely full, schema, table, and tablespace. In the full mode, the entire content of the export file is loaded. In the schema mode, all content from a list of schemas in the specified file, are loaded. In the table mode, only the specified tables and dependent objects are loaded. In the tablespace mode, all objects in the export file set are loaded. The Data Pump import mechanism uses the same parameters used by the Data Pump export.
68 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Table 4-2 describes the mapping of export modes to import modes.
Source Export Modes Database Schema Table Tablespace Live database Database Schema Live database Database Schema Table Tablespace Live database Database Schema Table Tablespace Live database
Import Mode Full
Schema
Table
Tablespace
Table 4-2: Mapping of Data Pump Export Modes to Import Modes To perform Data Pump import jobs using the impdp program, complete the following steps: 1. Connect as the SYSDBA user to the destination database. 2. Create a directory with the same name as created during exporting of the data using the expdp program. 3. Grant READ and WRITE permissions to the user, John, who wants to import the database. 4. Connect to destination database as the user, John. 5. Copy the expdp.dmp file to the destination database at the same location. 6. Type the following statement at the command prompt to invoke the Data Pump impdp program: C:/> impdp directory=directory_name When you type the above statement at the command prompt, you receive a prompt to type the user name and the password. 7. Type the user name and password at the command prompt. Data Pump starts importing data.
69 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Monitoring Data Pump Jobs You can monitor the progress of Data Pump jobs by either using the STATUS command in the interactivecommand mode interface or querying the DATA_DATAPUMP_JOBS, USER_DATAPUMP_JOBS, DBA_DATAPUMP_SESSIONS, and V$SESSION_LONGOPS views. You can use the DBA_DATAPUMP_JOBS and USER_DATAPUMP_JOBS views to display information about all the active Data Pump jobs, regardless of their status. These views also display information about all the master tables that are not associated with the active Data Pump job. After gathering the information about a master table, you can use that master table to restart a Data Pump job. Working with SQL*Loader SQL*Loader is a program that reads data files in different formats, parses the data, and loads the data into database tables. The various file types used by SQL*Loader are: •
log: Is a mandatory file that records the activities performed by SQL*Loader. If not specified, SQL*Loader creates a new log file in the current directory with the name of the control file and with a .log filename extension. Data loading is aborted if SQL*Loader is not able to create a log file.
•
control: Is a mandatory file that contains information about how the load should be performed. SQL*Loader reads this file to locate other data files, determine how to parse and load the data files, and determine the table into which to load the parsed data.
•
data: Is a file that contains the data that SQL*Loader reads and loads into the database.
•
bad: Is a file created by SQL*Loader that contains records that either cause errors during insert operations or are improperly formatted, and cannot be loaded. These records are not validated either by SQL*Loader or by the database.
•
discard: Is a file created by SQL*Loader that contains the data records that are not loaded because the records are not specified in the selection criteria.
You can invoke the SQL*Loader program by using the sqlldr command followed by one or more command-line parameters. You can identify these parameters either by their position on the commandline or with a keyword=value pair. Table 4-3 lists the SQL*Loader command-line parameters.
Parameter userid control log bad data discard
Description Specifies the database connect string. Specifies the name of the control file. Specifies the name of the log file. Specifies the name of bad file. Specifies the name of data file. Specifies the name of the discard file.
70 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Parameter discardmax skip load error rows bindsize direct parfile
Description Specifies the maximum number of discards allowed before data loading is terminated. Specifies the number of records to skip before loading the records. Specifies the number of records to load. Specifies the number of errors allowed before data loading is terminated. Specifies the number of rows in a conventional path bind array or between direct path data. Specifies the size of conventional path bind array in bytes. Specifies the load method to be used. Specifies the path and filename of a separate file containing additional command-line parameters. Table 4-3: SQL*Loader Command-Line Parameters
71 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Programming with PL/SQL Scope •
Identify various types of PL/SQL objects.
•
Describe triggers and triggering events.
•
Identify initialization parameters that affect PL/SQL performance.
Focused Explanation Identifying PL/SQL Objects Oracle Procedural Language Extension to SQL, also referred to as PL/SQL, is derived from the Ada programming language. PL/SQL has features, such as sequential and conditional controls, looping constructs, exception handling constructs, records, and collections. PL/SQL also has object-oriented features, such as method overloading and inheritance. The various types of PL/SQL objects are: functions, procedures, packages, and triggers. Working with Functions Functions are PL/SQL programs that execute the SQL statements and return a value through a RETURN statement. Oracle also provides built-in functions, such as SYSDATE, COUNT, and SUBSTR. A return data type is also associated with each function because the function returns value. Functions can be invoked within an expression of the compatible data type. The following are examples of declaring and using functions: Function declared as a default value: DECLARE today DATE DEFAULT SYSDATE; Function called in an assignment statement: Today := SYSDATE; Function called in a Boolean expression: IF TO_CHAR(SYSDATE,’DAY’) = ‘Monday’
72 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
You can also create a function using the CREATE FUNCTION statement. The following is an example of statements that create a function called is_weekend, which accepts a DATE parameter, check_date, returns ‘YES’ if the date is a weekend day, and returns ‘NO’ if the date is a weekday: CREATE OR REPLACE FUNCTION is_weekend (check_date IN DATE DEFAULT SYSDATE) RETURN VARCHAR2 AS BEGIN CASE TO_CHAR(check_date, ‘DY’) WHEN ‘SAT’ THEN RETURN ‘YES’; WHEN ‘SUN’ THEN RETURN ‘YES’; ELSE RETURN ‘NO’; END CASE; END; Functions can include the OR REPLACE clause in the CREATE FUNCTION statement. The OR REPLACE clause specifies that if the existing function already exists in the database, its definition will be overwritten with the new function definition. If you do not include the OR REPLACE clause with the CREATE FUNCTION statement and a function with the same name already exists in the database, an exception will be raised. Working with Procedures Procedures are PL/SQL programs that execute one or more SQL and PL/SQL statements. Procedures receive and return values only by using their parameter list. Oracle provides fewer built-in procedures than built-in functions. You can create a procedure using the CREATE PROCEDURE statement. The following is an example of the statements to create a procedure named demo_proc, which executes a SELECT statement against the emp table to retrieve an employee’s name and displays the employee name: CREATE OR REPLACE PROCEDURE demo_proc IS ename1 varchar2(20); BEGIN SELECT ename INTO ename1 FROM emp WHERE empno=7369; DBMS_OUTPUT.PUT_LINE(‘employee name=‘||ename1); END; The IS clause in the procedure is the synonym of AS in the function description. You can invoke a procedure as a stand-alone statement within a PL/SQL program by using the CALL or EXEC statements. Working with Packages A package is a container for procedures, functions, and other data structures, such as records, cursors, variables, and constants. A package is divided into two sections, the public section is called the package specification, and the private section is called the package body. The package specification includes
73 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
declarations for the procedures, functions, and data structures that can be accessed from other programs. The package body contains programming statements for procedure and function implementations. You can use the CREATE PACKAGE statement to create a package specification. The following example creates a package specification for the package named table_util, which has a version1 function and a truncate1 procedure that can be accessed by other programs: CREATE OR REPLACE PACKAGE table_util IS FUNCTION version1 RETURN VARCHAR2; PROCEDURE truncate1 (table_name IN VARCHAR2); END table_util; You can grant privileges on a package at the package specification level. The EXECUTE privilege allows you to execute any program or use any data structure declared in the package specification. To fully implement a package, you must declare a package body with the same name as the package specification. You cannot declare a package body without first declaring the package specification. The package body contains programming statements that implement the procedures, functions, and data structures that are declared in the package specification. You can use the CREATE PACKAGE BODY statement to create a package body. The following is an example of a package body, which is named table_util and implements a function named version1, and a procedure named truncate1: CREATE OR REPLACE PACKAGE BODY table_util IS version_string VARCHAR2(8) :='1.0.0'; FUNCTION version1 RETURN VARCHAR2 IS BEGIN RETURN version_string; END; PROCEDURE truncate1 (table_name IN VARCHAR2) IS BEGIN IF UPPER(table_name) = 'ORDER_STAGE' THEN EXECUTE IMMEDIATE 'TRUNCATE TABLE' || UPPER(table_name); ELSE RAISE_APPLICATION_ERROR(-20010, 'Invalid table for truncate'); END IF; END; END table_util; In this package body, the version1 function returns the version_string string. The truncate1 procedure in the package body deletes all the rows from a table using the TRUNCATE TABLE statement if the name of the table is order_stage or ORDER_STAGE otherwise an error, Invalid table for truncate, is raised. Triggers and Triggering Events PL/SQL programs that are invoked in response to an event in the database are called triggers. You can create triggers on DML events, DDL events, and database events.
74 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
DML Event Triggers DML triggers fire when the DML event specified by the trigger definition occurs. When you include the FOR EACH ROW clause in the trigger definition, the trigger is fired once for each row that is affected by the DML statement. If the DML event list includes the UPDATE event, the trigger can be further restricted to fire only when updates of specific columns occur. The following example creates a trigger that fires before any insert or any update of the ename column takes place on the empl table: CREATE OR REPLACE TRIGGER emp_trig1 BEFORE INSERT OR UPDATE OF ename ON empl FOR EACH ROW BEGIN IF :new.name not like '%SMITH%' THEN RAISE_APPLICATION_ERROR(-20000, 'No People Named Smith Allowed!'); END IF; END; Table 4-4 shows the DML triggering events and their descriptions.
DML Triggering Event INSERT UPDATE DELETE
Description Is fired when a row is added to a table or a view. Is fired when an UPDATE statement changes a row in a table or a view. Is fired when a row is removed from a table or a view. Table 4-4: DML Triggering Events
If you define multiple triggers on a table, then these triggers fire in the following sequence: 1. Before statement triggers 2. Before row triggers 3. After row triggers 4. After statement triggers DDL Event Triggers DDL triggers fire when DDL changes occur for a specific schema or all the schemas in a database. When you specify the ON DATABASE clause, the trigger is fired for the specific event on any schema in the database.
75 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Table 4-5 lists the DDL triggering events and their descriptions.
DDL Triggering Event ALTER ANALYZE
Description Is fired when an ALTER statement changes a database object. Is fired when a database validates the structure and gathers or deletes the statistics. Is fired when the ASSOCIATE STATSTICS statement is used to associate a statistic type with a database object. Is fired when a database records an audit action. Is fired when a comment on a table or a column is modified. Is fired when a database object is created. Is fired when a DISASSOCIATE STATISTICS statement is used to disassociate a statistic type from a database object. Is fired when a DROP statement removes an object from a database. Is fired when a GRANT statement assigns a privilege. Is fired when a NOAUDIT statement changes database auditing. Is fired when a RENAME statement changes an object name. Is fired when a REVOKE statement revokes a privilege. Is fired when a TRUNCATE statement purges a table.
ASSOCIATE STATISTICS AUDIT COMMENT CREATE DISASSOCIATE STATISTICS DROP GRANT NOAUDIT RENAME REVOKE TRUNCATE
Table 4-5: DDL Triggering Events Database Event Triggers Database event triggers are fired when the specified database events occur. Table 4-6 lists the database triggering events and their descriptions.
Database Triggering Event LOGON LOGOFF STARTUP SHUTDOWN SERVERERROR SUSPEND
Description Is fired after a client application successfully logs on to the database. Is fired before a client application logs off the database. Is fired immediately after a database is opened. Is fired immediately before a database shuts down. Is fired after a server error message is logged. Is fired when a server error causes a transaction to be suspended.
Table 4-6: Database Triggering Events
76 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Initialization Parameters for PL/SQL Performance The initialization parameters that affect the performance of PL/SQL are: •
PLSQL_WARNING – Enables you to use compiler warnings to identify potential problems that can generate run-time errors.
•
PLSQL_DEBUG – Interrupts all subsequent PL/SQL compilations and includes additional debugging information.
•
PLSQL_OPTIMIZE_MODE – Optimizes the compiler to improve PL/SQL performance.
•
PLSQL_CODE_TYPE – Specifies whether to compile the PL/SQL code into the default-interpreted byte code or native machine code.
77 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Managing Data and Programming with PL/SQL: Oracle 10g Administration I Describe database interfaces. Learn how to query tables using SQL statements. Learn how to create tables using SQL statements. Describe data manipulation using INSERT, UPDATE, and DELETE statements. Describe how to export and import data using the Data Pump. Describe how to work with SQL*Loader and create directory objects. Identify various types of PL/SQL objects. Describe triggers and triggering events. Identify initialization parameters that affect PL/SQL performance.
78 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Managing Users and Securing Databases: Oracle 10g Administration I
79 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Administering Database Users Scope •
Describe how to create and manage user accounts.
•
Identify the object privileges and describe how to grant and revoke privileges.
•
Understand the process and recognize the syntax for creating and managing roles.
•
Define the options available to control resource usage.
Focused Explanation Creating and Managing User Accounts A database user requires a user account to connect to an Oracle database. You can create a user account using the CREATE USER statement. The following are various attributes to be assigned to a user account when creating the user account: •
Authentication method
•
Default tablespace
•
Temporary tablespace
•
Profile
Assigning an Authentication Method for a User Account Authentication refers to the process of validating the identity of a user and ensuring that the user has the permission to use the database. An Oracle server authenticates a user when the user connects to an Oracle database instance. The methods to authenticate a user are as follows: •
Password authentication – Authenticates a user using a password.
•
External authentication – Authenticates a user using an operating system or a network service.
•
Global authentication – Authenticates a user using advanced security options, such as Kerberos and X.509 certificates.
Creating a Password-Authenticated User Account A user account that needs to be authenticated by a password is called a password-authenticated user account. The following syntax shows how to create a password-authenticated user account: CREATE USER user_name IDENTIFIED BY password;
80 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
In this syntax: •
user_name – Specifies a unique user name for the user account. The user name is not casesensitive and cannot be a reserved word.
•
IDENTIFIED BY - Specifies that the user account is a password-authenticated user account.
•
password – Specifies the password for the user account. An Oracle database stores this password in the data dictionary in an encrypted form.
Creating an Externally-Authenticated User Account In an externally authenticated user account, an Oracle database verifies the validity of a user name. The Oracle database confirms that the user is authenticated by an operating system or a network service, such as Oracle Net. To create an externally-authenticated user account, a user must have an operating system account. The following syntax shows how to create an externally-authenticated user account: CREATE USER user_name IDENTIFIED EXTERNALLY; In this syntax: •
user_name – Specifies a unique user name for the user account.
•
IDENTIFIED EXTERNALLY – Specifies that authentication for the user is done by an operating system or a network service.
Creating a Globally-Authenticated User Account In a globally-authenticated user account, an Oracle database validates the user name and confirms authentication using a service that is supported by the advanced security options. The advanced security options support services, such as Kerberos, X.509 certificates, and RADIUS. The following syntax shows how to create a globally-authenticated user account: CREATE USER user_name IDENTIFIED GLOBALLY AS ‘CN= analyst, OU=tier2, O=security, c=US’; In this statement, the parameter, user_name, refers to the name of the user account to be created. The string provided in the AS clause specifies a unique name for user_name in the enterprise directory. Assigning a Default Tablespace When you create a user account, the Oracle database instance assigns a default tablespace to the user account. The default tablespace stores database objects, such as tables and indexes, created by the user account. If you do not specify a tablespace for storing the database objects when creating them, these objects are stored in the default tablespace. You can use one of the following statements to assign a default tablespace to a user account:
81 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
The DEFAULT TABLESPACE clause with the CREATE USER statement when creating a new user account
•
The DEFAULT TABLESPACE clause with the ALTER USER statement when altering an existing user account
The following is an example of creating a new user account with a default tablespace: CREATE USER nik IDENTIFIED BY engineer DEFAULT TABLESPACE users; This statement creates a password-authenticated user account with the user name nik, password engineer, and a default tablespace users. The following example shows how to assign a default tablespace to an existing user account: ALTER USER nik DEFAULT TABLESPACE sales_data; This statement assigns a default tablespace, sales_data, to a user nik. You can change the default tablespace for a database instance by using the DEFAULT TABLESPACE clause with the ALTER DATABASE statement. The following is an example that shows how to change the default tablespace of an Oracle database instance to sales_data: ALTER DATABASE DEFAULT TABLESPACE sales_data; Assigning a Temporary Tablespace A temporary tablespace represents a logical group of temporary database segments. These temporary database segments are created during sorting operations, such as ORDER BY, GROUP BY, and CREATE INDEX. You can use one of the following statements to assign a temporary tablespace to a user account: •
TEMPORARY TABLESPACE clause with the CREATE USER statement when creating a new user account
•
TEMPORARY TABLESPACE clause with the ALTER USER statement when altering an existing user account
The following is an example of creating a temporary tablespace when creating a new user account: CREATE USER nik IDENTIFIED BY engineer DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp; This statement creates a password-authenticated user account with the user name nik, password engineer, a default tablespace users, and a temporary tablespace temp.
82 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following example shows how to assign a temporary tablespace, sales_data, to an existing user account, nik: ALTER USER nik TEMPORARY TABLESPACE sales_data; If you do not explicitly specify a temporary tablespace for a user account, the user account uses the default temporary tablespace. You can change the default temporary tablespace for a database instance using the TEMPORARY TABLESPACE clause with the ALTER DATABASE statement. The following is an example of changing the default temporary tablespace of an Oracle database instance to sales_data: ALTER DATABASE TEMPORARY TABLESPACE sales_data; Assigning a Profile to a User Account A profile refers to a set of parameters that specify the resource usage of the host computer on which a database instance is running. A profile is used to limit the use of resources on the host computer and enforce password-management rules on the database instance. You can assign a profile to a user account using either of the following statements: •
PROFILE keyword with the CREATE USER statement when creating a new user account
•
PROFILE keyword with the ALTER USER statement when altering an existing user account
The following is an example of creating a user profile when creating a new user account: CREATE USER nik IDENTIFIED BY engineer DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp PROFILE user_profile; This statement creates a password-authenticated user account with the user name nik, password engineer, a default tablespace users, a temporary tablespace temp, and a profile user_profile. The following example shows how to assign a profile, resource_profile to an existing user account, nik: ALTER USER nik profile resource_profile; Removing a User Account You can remove a user account from a database using the DROP USER statement. Removing a user account does not remove the database objects associated with the user account. To remove the database objects associated with a user account, you can use the CASCADE keyword with the DROP USER statement. The following is an example of removing a user account from a database: REMOVE USER nik CASCADE;
83 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
This statement removes the user nik and the database objects associated with the user. Removing a user implicitly removes all the object privileges granted by the user, but does not remove the system privileges and roles. Introducing Database Privileges Database privileges refer to authorizations assigned to a user for performing operations on a database. The following are the different types of database privileges that you can assign to a user in Oracle 10g: •
Object privileges – Refers to authorizations assigned to a user to perform operations on database objects, such as tables, sequences, views, packages, and procedures.
•
System privileges – Refers to authorizations assigned to a user to perform database-level operations, such as creating users, altering a database, and connecting to a database instance.
•
Role privileges – Refers to a set of privileges, if a user is assigned a role. A role is a set of privileges used to administer privileges.
Granting Object Privileges Based on the type of database object, you can grant the following object privileges to a user account: •
Table object privileges
•
View object privileges
•
Sequence object privileges
•
Stored functions, procedures, packages, and Java object privileges
Table Object Privileges Table object privileges authorize other database users to perform operations on the tables owned by a user account. The following are commonly used table object privileges that can be granted to other users by the user account that owns the table: •
SELECT – Enables the grantee to query the specified table using a SELECT statement.
•
INSERT – Enables the grantee to insert rows into the specified table using an INSERT statement.
•
UPDATE – Enables the grantee to modify the data in the specified table using an UPDATE statement.
•
DELETE – Enables the grantee to delete rows from the specified table using a DELETE statement.
•
ALTER – Enables the grantee to alter the specified table using an ALTER TABLE statement.
•
DEBUG – Enables the grantee to access PL/SQL code of triggers on the specified table using a debugger.
84 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
INDEX – Enables the grantee to create new indexes on the specified table.
•
REFERENCES – Enables the grantee to create a foreign key that references the specified table.
View Object Privileges View object privileges authorize other database users to perform operations on views owned by a user account. The following are commonly used view object privileges that can be granted to users by the user account that owns the view: •
SELECT – Enables the grantee to query the specified view using a SELECT statement.
•
INSERT – Enables the grantee to insert rows into the underlying table of the specified view using an INSERT statement.
•
UPDATE – Enables the grantee to modify the rows in the underlying table of the specified view using an UPDATE statement.
•
DELETE – Enables the grantee to remove rows from the underlying table of the specified view using a DELETE statement.
•
DEBUG – Enables the grantee to access PL/SQL code of triggers on the specified view using a debugger.
•
REFERENCES – Enables the grantee to create a foreign key that references the specified view.
Sequence Object Privileges Sequence object privileges authorize other database users to perform operations on sequences owned by a user account. There are two object privileges for sequences: •
SELECT – Enables the grantee to access current and next values of the specified sequence using a SELECT statement.
•
ALTER – Enables the grantee to modify the attributes of the specified sequence using an ALTER SEQUENCE statement.
Stored Functions, Procedures, Packages, and Java Object Privileges There are two object privileges for stored PL/SQL programs: •
DEBUG – Enables the grantee to access the public and private variables and types declared in the specified PL/SQL program.
•
EXECUTE – Enables the grantee to execute the specified PL/SQL program.
85 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Granting Object Privileges You use the GRANT statement to grant object privileges either to a user or to a role. The following is an example of granting privileges to a user by using the GRANT statement: GRANT SELECT,INSERT,UPDATE,DELETE ON EMPLOYEE TO manager; This statement grants the SELECT, INSERT, UPDATE, and DELETE privileges on the EMPLOYEE table, to the user manager. You can use the WITH GRANT OPTION clause with the GRANT statement to enable a grantee to subsequently grant privileges to another user. The WITH GRANT OPTION clause enables a grantee to grant only those privileges that are granted to the grantee. The following is an example of granting object privileges using the WITH GRANT OPTION clause with the GRANT statement: GRANT SELECT ON EMPLOYEE TO manager WITH GRANT OPTION; This statement grants the SELECT privilege on the EMPLOYEE table to the manager user and also permits this user to grant the SELECT privilege to other users of the EMPLOYEE table. You cannot use the WITH GRANT OPTION clause when the grantee is a role. When you revoke the privilege given using the WITH GRANT OPTION, the privileges given to other users by the grantee are also revoked. You can use the PUBLIC keyword to grant object privileges on a table to all the existing users in a database. The following is an example of granting SELECT object privileges on the EMPLOYEE table to all users by using the PUBLIC keyword with the GRANT statement: GRANT SELECT ON EMPLOYEE TO PUBLIC; Granting System Privileges System privileges enable a grantee to perform system-level operations, such as connecting to a database, auditing the database, managing profiles and roles, creating and managing tablespaces, and creating and managing user accounts. Oracle defines more than 100 system privileges that can be assigned to a user or a role. You can retrieve the information about various system privileges from the SYSTEM_PRIVILEGE_MAP view. Creating and Managing Roles You can grant a set of privileges to a role and use this role to grant all these privileges to another role or user. When you grant privileges to a user or another user using a role, you do not need to grant the privileges in the role to the user or role separately. You create a role using the CREATE ROLE statement. You can use the IDENTIFIED BY clause to confirm the authentication of a user before enabling the role granted to the user. The following is the syntax for creating a role: CREATE ROLE new_role; In this syntax, new_role specifies the name of the role you want to create.
86 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following is the syntax for enabling a role: SET ROLE role_name IDENTIFIED BY mypassword; In this syntax: •
role_name – Refers to the name of the role to be enabled.
•
mypassword – Refers to the password that is required to confirm the authentication of a user before enabling the role that is granted to the user.
Granting Roles You can grant a role to another role or to a user using the GRANT statement. The following is an example of granting a role, new_role, to a user, nik: GRANT new_role TO nik; You can use the PUBLIC keyword to grant a role to all the users in a database. You can use the WITH ADMIN OPTION clause to permit a role to grant the privileges granted to the role to other users and roles. The following syntax shows how to grant a privilege to a role using the WITH ADMIN OPTION clause: GRANT privilege_name TO role_name WITH ADMIN OPTION; In this statement, the privilege_name parameter refers to the name of the privilege granted to a role and role_name refers to the name of the role to which the role wants to grant the privilege_name privilege. Enabling Roles You can enable roles in a database session using the SET ROLE statement and specifying a list of roles to be enabled. The roles in the list are separated by commas. The following is the syntax for enabling a set of roles: SET ROLE role_list; In this statement, the role_list parameter refers to a list of roles separated by commas. You can enable a role associated with a password using the IDENTIFIED BY password clause with the SET ROLE statement. The following is the syntax for enabling a role associated with a password: SET ROLE new_role IDENTIFIED BY mypassword; You can use the SET ROLE ALL statement to enable all roles for a user. You can specify a list of roles to be excluded using the EXCEPT exclusion_list clause with the SET ROLE ALL statement. The exclusion_list refers to a comma-separated list of roles to be excluded. You can query the SESSION_ROLES view to identify the roles that are enabled in a database session.
87 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Disabling Roles Oracle 10g allows you to only disable all the roles in a database session. You can disable all roles using the SET ROLE ALL NONE statement. However, you cannot disable a single role. The roles that you inherit from a parent role are disabled when the parent role is disabled. Setting Default Roles Default roles refer to the roles that are enabled by default when a user logs on to a database instance. Default roles do not need a password. You also do not need to execute the SET ROLE statement to enable the default roles. You can change the default roles assigned to a user using the ALTER USER user_name DEFAULT ROLE role_list statement. The user_name parameter specifies the name of the user for which you want to change the default roles. The role_list parameter refers to a comma-separated list of roles used as default roles. You can also use keywords such as ALL, EXCEPT, and NONE, as the role_list parameter. The maximum number of default roles is determined by the MAX_ENABLED_ROLES initialization parameter. If the number of default roles is more than the value of MAX_ENABLED_ROLES, an exception is raised and the user logon fails. Controlling Resource Usage A user account consumes various resources, such as disk space, CPU, and memory. Tablespace quotas define the maximum limit of disk space that user accounts can consume. Profiles define the maximum limit of the CPU and memory usage consumed by the user accounts in a database. Assigning Tablespace Quotas A tablespace quota for a user account defines the limit on the amount of space the database objects associated with the user account can occupy within a tablespace. You can specify the tablespace quota for a user account using the QUOTA amount_of_space ON tbs_name clause with the CREATE USER statement. The amount_of_space parameter refers to the limit on space in a tablespace, and the tbs_name parameter refers to the name of the tablespace. The following is an example of creating a user account with the specified tablespace quota: CREATE USER nik IDENTIFIED BY nik1 QUOTA 100M ON USERS; This statement defines a limit of 100M on the amount of space, which the database objects associated with the user account, nik, can occupy within the USERS tablespace. You can define a tablespace quota for an existing user account using the QUOTA amount_of_space ON tbs_name clause with the ALTER USER statement. You can use the UNLIMITED keyword instead of the amount_of_space parameter to specify that the user has unlimited space in a tablespace occupied by the database objects owned by the user.
88 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Assigning Resource Limits with a Profile A profile helps you to manage resources, such as CPU time, memory, and the number of read operations performed during a user session. To limit resource consumption using a profile, you must set the RESOURCE_LIMIT initialization parameter to TRUE. You can set the RESOURCE_LIMIT parameter using the ALTER SYSTEM statement, for example: ALTER SYSTEM SET RESOURCE_LIMIT=TRUE SCOPE=BOTH; You can assign resource limits to a profile using the CREATE PROFILE or ALTER PROFILE statement. The following are various clauses that are used with the CREATE PROFILE and ALTER PROFILE statements to limit resources: •
CONNECT_TIME – Specifies the maximum time for a session. If a session exceeds the specified amount of time, the uncommitted transactions are rolled back and the session is terminated.
•
CPU_PER_CALL – Specifies the maximum limit of CPU time that can be consumed by a single CPU call for a SQL statement. If a CPU call exceeds this limit, the SQL statement fails and an exception is raised.
•
CPU_PER_SESSION – Specifies the maximum limit of CPU time consumed in a session. If a session exceeds the specified amount of time, the current statement executing in the session fails, the transaction containing the current statement is automatically rolled back, and an exception is raised. When the exception is raised, the user is allowed to commit or roll back the changes before logging off.
•
IDLE_TIME – Specifies the maximum limit on the amount of time between two database calls during a session. If this limit is exceeded, the current SQL statement is executed but the next SQL statement fails. The user is allowed to either commit or roll back the changes before logging off.
•
LOGICAL_READS_PER_CALL – Specifies the maximum limit on the number of logical reads performed by a database call. If a database call exceeds this limit, the database rolls back the current SQL statement and sends an error to the calling program. The database allows the user to commit or roll back the changes.
•
LOGICAL_READS_PER_SESSION – Specifies the maximum limit on the number of logical reads performed in a session. If this limit is exceeded, the current statement fails and an exception is raised. When the exception is raised, the user either commits or rolls back the changes and ends the session.
•
PRIVATE_SGA – Specifies a limit on the amount of System Global Area (SGA) memory used.
•
SESSIONS_PER_USER – Specifies a limit on the number of sessions for a user account.
89 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Securing Databases Scope •
Learn how to apply the principle of least privilege.
•
Describe how to manage default user accounts.
•
Discuss how to implement standard password security features.
•
Identify how to audit database activities.
Focused Explanation Applying the Principle of Least Privilege The principle of least privilege states that the users in a database must be granted minimal privileges to perform database operations. To apply the principle of least privilege, you need to perform the following checks on a database: •
Secure the data dictionary to ensure that the users granted the SELECT ANY TABLE privilege are not able to access the tables in the data dictionary. You can secure the data dictionary by setting the value of the 07_DICTIONARY_ACCESSIBILTY initialization parameter to FALSE. The default value of the 07_DICTIONARY_ACCESSIBILTY initialization parameter is TRUE.
•
Revoke unnecessary privileges on packages and roles from the PUBLIC user. To revoke privileges from the PUBLIC user, you need to revoke the EXECUTE privilege from the following packages:
•
o
UTL_TCP – Allows the grantee to establish a network connection with a waiting TCP/IP network service.
o
UTL_SMTP – Allows the grantee to send arbitrary e-mail messages over a network.
o
UTL_HTTP – Allows the grantee to send and receive arbitrary data using the HTTP protocol.
o
UTL_FILE – Allows the grantee to read and write data to operating system files.
o
DBMS_OBFUSCATION_TOOLKIT and DBMS_CRYPTO – Allows the grantee to encrypt data.
Grant administrative privileges to limited users. The following are some of the administrative privileges and roles that you need to revoke: o
SYSDBA – Gives the grantee the highest level of privileges in the database. You should be cautious in granting this type of privilege because the user with the SYSDBA role can bypass most of the security features provided by a database. This type of privilege should only be given to the SYS user account.
90 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
o
DBA – Gives the grantee the authority to assign privileges to other users and manipulate data in a database. You should be cautious in granting this type of privilege because the user with the DBA role can bypass most of the security features provided by a database.
o
The ANY system privileges – Gives the grantee the authority to assign privileges to other users and manipulate data in a database.
Set the REMOTE_OS_AUTHENT initialization parameter to FALSE, to disable this initialization parameter. When the value of this initialization parameter is set to TRUE, this initialization parameter instructs the database to authorize a client to authenticate external user accounts.
Managing Default User Accounts The SYS and SYSTEM user accounts are the default user accounts that are always created when you create an Oracle 10g database. The SYS account is a data dictionary owner account, and the SYSTEM account is an administrative account. In addition to these accounts, the SYSMAN and DBSNMP accounts are also created when you create a database using the Database Configuration Assistant (DBCA). There are certain default users, such as SYS, SYSTEM, and OUTLN, which cannot be dropped from a database. Changing the Password of Default User Accounts The password of default user accounts can be changed using SQL statements. The following is the syntax for changing the password of default user accounts: ALTER USER user_name IDENTIFIED BY new_password; In this statement the parameter, user_name, refers to the name of the user account and the parameter new_password refers to the new password for this user account. You can change the password of a user account by typing password at the SQL prompt after logging on to a database. Changing Quota of the Default User Accounts The quota allocated to default user accounts can also be changed using SQL statements. The following is the syntax for changing the quota for default user accounts: ALTER USER user_name QUOTA UNLIMITED ON tablespace_name; In this syntax: •
user_name – Refers to the name of the user account.
•
tablespace_name – Refers to the name of the tablespace.
Implementing Standard Password Security Features Password security rules and password-complexity rules are enforced on a database using profiles and verification functions, respectively. A profile contains a set of standard rules that define various password characteristics.
91 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following are the characteristics defined by a profile: •
The validity of a password
•
The number of days a password is allowed to be active
•
The number of password changes that must occur before a previously used password can be reused
•
The maximum number of failed login attempts that a user is allowed to perform
•
The time for which a user account will be locked
You can create a profile using the CREATE PROFILE statement. You can also alter an existing profile using the ALTER PROFILE statement. These SQL statements support the following parameters to configure standard password rules: •
FAILED_LOGIN_ATTEMPTS – Specifies the maximum number of failed login attempts that a user is allowed to perform. A user account is locked if the user associated with the user account exceeds the limit specified by the FAILED_LOGIN_ATTEMPTS parameter.
•
PASSWORD_LOCK_TIME – Specifies the time, in days, up to which a user account is locked. The password lock time starts after the user fails to log on to a database in the allowed number of attempts.
•
PASSWORD_LIFE_TIME – Specifies the maximum number of days a password is allowed to be active.
•
PASSWORD_GRACE_TIME – Specifies the number of days for which a user is allowed to login after the user’s password has expired. The user will be reminded to change the password during this period.
•
PASSWORD_REUSE_TIME – Specifies the minimum number of days that must elapse before a password can be reused.
•
PASSWORD_REUSE_MAX – Specifies the minimum number of password changes that must occur before a previously used password can be reused.
Auditing Database Activity Auditing involves monitoring and recording specific database activities, such as execution of SQL statements. Oracle 10g allows you to audit database activities at the following four levels: •
Statement auditing – Monitors and records the execution of SQL statements.
•
Privilege auditing – Monitors and records the execution of SQL statements that require specific system privileges, such as SELECT ANY TABLE or GRANT ANY PRIVILEGE, to execute.
92 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Object auditing – Monitors and records the execution of SQL statements that require specific object privileges, such as SELECT, INSERT, or EXECUTE, to execute.
•
Fine-grained auditing (FGA) – Monitors and records data access based on the content of the data being accessed.
You can record database activities in databases or operating system files. The entries in the databases or operating system files are referred to as audit records. You can specify the location of audit records by setting the value of the AUDIT_TRAIL initialization parameter. You can assign one of the following three values to the AUDIT_TRAIL initialization parameter: •
DB – Specifies that audit records are stored in a database.
•
DB_EXTENDED – Specifies that audit records are stored in a database along with the SQL statement that triggers the audit entry.
•
OS – Specifies that audit records are stored in operating system files.
You can change the location of the audit records by using the ALTER SYSTEM statement. For example, to store the audit records in a database, type the following statement at the SQL prompt: ALTER SYSTEM SET AUDIT_TRAIL=DB SCOPE=SPFILE; You need to restart the database after changing the value of the AUDIT_TRAIL initialization parameter. Enabling Statement Auditing Statement auditing is a process that enables auditing of specific SQL statements such as CREATE TABLE and DROP TABLE. You can enable statement auditing using the AUDIT statement. For example, to enable auditing of SQL statements, such as CREATE TABLE, TRUNCATE TABLE, and DROP TABLE, type the following statement at the SQL prompt: AUDIT TABLE; You can also enable auditing for specific users by using the BY USER clause in the AUDIT statement. For example, to audit records for the user, John, type the following statement at the SQL prompt: AUDIT TABLE BY John; You can also enable auditing of non-DDL statements, such as INSERT TABLE or ALTER TABLE, by specifying the BY ACCESS clause in the AUDIT statement. For example, to enable auditing for the INSERT TABLE statement, type the following statement at the SQL prompt: AUDIT INSERT TABLE BY SCOTT BY ACCESS;
93 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Viewing Information about Statement Auditing You can query the DBA_STMT_AUDIT_OPTS data dictionary view to display information about statement auditing. To query the DBA_STMT_AUDIT_OPTS data dictionary view, type the following statement at the SQL prompt: SELECT AUDIT_OPTION, USER_NAME FROM DBA_STMT_AUDIT_OPTS ORDER BY AUDIT_OPTION; Disabling Statement Auditing You can disable statement auditing by using the NOAUDIT statement. For example, to disable the auditing of SQL statements, such as CREATE TABLE, TRUNCATE TABLE, and DROP TABLE, type the following statement at the SQL prompt: NOAUDIT TABLE; You can also disable auditing for specific users by using the BY clause in the NOAUDIT statement. For example, to disable auditing of specific SQL statements for the user John, type the following statement at the SQL prompt: NOAUDIT TABLE BY John; Enabling Privilege Auditing You can enable privilege auditing using the AUDIT statement. For example, to enable privilege auditing of the SQL statements that require the CREATE ANY TABLE system privilege, type the following statement at the SQL prompt: AUDIT CREATE ANY TABLE; You can also enable privilege auditing for specific users by using the BY clause in the AUDIT statement. For example, to audit the SQL statements executed by the user John, type the following statement at the SQL prompt: AUDIT CREATE ANY TABLE BY John; Viewing Information about Privilege Auditing The DBA_PRIV_AUDIT_OPTS data dictionary view displays information about privilege auditing. To query the DBA_PRIV_AUDIT_OPTS data dictionary view, type the following statement at the SQL prompt: SELECT PRIVILEGE,USER_NAME FROM DBA_PRIV_AUDIT_OPTS ORDER BY PRIVILEGE;
94 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Disabling Privilege Auditing You can disable privilege auditing by using the NOAUDIT statement. For example, to disable the auditing of the ALTER PROFILE statement, type the following statement at the SQL prompt: NOAUDIT ALTER PROFILE; You can also disable privilege auditing for specific users by using the BY clause in the NOAUDIT statement. For example, to disable privilege auditing for the user John, type the following statement at the SQL prompt: NOAUDIT ALTER PROFILE BY John; Enabling Object Auditing You can enable object auditing using the AUDIT statement. You need to specify the object and the object privilege you want to audit in the AUDIT statement. For example, to enable auditing of the SELECT statement on the EMPLOYEE table, type the following statement at the SQL prompt: AUDIT SELECT ON EMPLOYEE; You cannot enable object auditing for a specific user. Object auditing is enabled either for all the users in a database or for none. Viewing Information About Object Auditing The DBA_OBJ_AUDIT_OPTS data dictionary view displays information about object auditing. The DBA_OBJ_AUDIT_OPTS data dictionary view contains one row for each auditable object in a database. This view also contains columns for each object privilege on which you can enable auditing. For example, to view the object auditing options of the EMPLOYEE table, type the following statement at the SQL prompt: SELECT OWNER,OBJECT_TYPE, INS, SEL FROM DBA_OBJ_AUDIT_OPTS WHERE OBJECT_NAME=‘EMPLOYEE’; Disabling Object Auditing You can disable object auditing using the NOAUDIT statement. For example, to disable auditing of the SELECT statement on the EMPLOYEE table, type the following statement at the SQL prompt: NOAUDIT SELECT ON EMPLOYEE; You can also disable auditing of the SQL statements that are not executed, by specifying the WHENEVER NOT SUCCESSFUL clause in the NOAUDIT statement. To disable the auditing of the SELECT statements that are not executed, type the following statement at the SQL prompt: NOAUDIT SELECT ON EMPLOYEE WHENEVER NOT SUSCCESSFUL;
95 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Examining the Audit Records Statement, privilege, and object audit records are stored in the SYS.AUD$ table. You can view audit records by querying the DBA_AUDIT_TRAIL and USER_AUDIT_TRAIL data dictionary views. To query the DBA_AUDIT_TRAIL data dictionary view for the user John, type the following statement at the SQL prompt: SELECT USERNAME, TIMESTAMP, ACTION_NAME FROM DBA_AUDIT_TRAIL WHERE USERNAME=‘John’; Purging Audit Records You need to purge audit records for statement, privilege, and object auditing from the SYS.AUD$ table at regular intervals. To delete purged audit records from the SYS.AUD$ table by using the DELETE statement, type the following statement at the SQL prompt: DELETE FROM SYS.AUD$ WHERE TIMESTAMP < SYSDATE-15; This statement purges the audit records from the SYS.AUD$ table that are older than 15 days. Creating an FGA Policy FGA auditing allows you to create an FGA policy on a table, and on the columns of a table. When the condition specified in the FGA policy evaluates to TRUE, an audit record is created and an optional eventhandler is called. You can create an FGA policy using the ADD_POLICY procedure. The following are the some of the arguments of the ADD_POLICY procedure: •
object_schema – Specifies the owner of the database object on which you want to create an FGA policy. The default value of the object_schema argument is the current user’s schema.
•
object_name – Specifies the name of the database object on which you want to create an FGA policy.
•
policy_name – Specifies the name of the FGA policy you want to create.
•
audit_condition – Specifies a SQL expression, which evaluates to a Boolean value. Audit records are created when the condition specified in the SQL expression evaluates to TRUE or NULL.
•
audit_column – Specifies a comma-delimited list of columns that are accessed by a SQL statement. If a column specified in the audit_column argument is referenced in a SQL statement and the audit_condition argument evaluates to TRUE, an audit record is created.
•
handler_schema – Specifies the owner of the event-handler procedure that is called when an audit record is created.
96 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
handler_module – Specifies the name of the event-handler procedure. The default value of the handler_module argument is NULL, which specifies that event-handler module should not be used.
•
enable – Specifies whether or not the current FGA policy should be enabled. The enable argument accepts either of the two values, TRUE or FALSE. The TRUE value specifies that the current FGA policy should be enabled. The FALSE value specifies that the current FGA policy should not be enabled. The default value of the enable argument is TRUE.
•
statement_types – Specifies the type of SQL statements to be monitored during auditing. The statement_types argument can accept a comma-delimited list of SQL statements, including SELECT, INSERT, UPDATE, or DELETE. The default value of the statement_types argument is SELECT.
•
audit_trail – Specifies whether or not to record the SQL statement that creates an audit record and the bind variables for the SQL statement.
For example, you want to create an FGA policy, issue_policy, which audits the SELECT statements issued on the EMPLOYEE table. You want the SQL statements that reference either the empno or the salary columns in the EMPLOYEE table to be audited. Type the following statements at the SQL prompt to create the FGA policy: BEGIN DBMS_FGA.ADD_POLICY( object_schema =>‘HR’, object_name =>‘EMPLOYEE’, policy_name =>‘issue_policy’, audit_column =>‘salary,empno’, statement_types =>‘SELECT,INSERT’); END; Enabling an FGA Policy By default, an FGA policy is enabled when you create it. You can explicitly enable a disabled FGA policy using the ENABLE_POLICY procedure. For example, to enable the issue_policy FGA policy, type the following statements at the SQL prompt: BEGIN DBMS_FGA.ENABLE_POLICY( object_schema =>‘HR’, object_name =>‘EMPLOYEE’, policy_name =>‘issue_policy’); END;
97 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Disabling an FGA Policy You can disable an FGA policy using the DISABLE_POLICY procedure. For example, to disable the issue_policy FGA policy, type the following statements at the SQL prompt: BEGIN DBMS_FGA.DISABLE_POLICY( object_schema =>‘HR’, object_name =>‘EMPLOYEE’, policy_name =>‘issue_policy’); END; Dropping an FGA Policy You can drop an FGA policy using the DROP_POLICY procedure. To drop the issue_policy FGA policy, type the following statements at the SQL prompt: BEGIN DBMS_FGA.DROP_POLICY( object_schema =>‘HR’, object_name =>‘EMPLOYEE’, policy_name =>‘issue_policy’); END; Identifying FGA Policies in a Database You can query the DBA_AUDIT_POLICIES data dictionary view to identify the FGA policies in a database. To query the DBA_AUDIT_POLICIES data dictionary view, type the following statement at the SQL prompt: SELECT POLICY_NAME, SCHEMA_NAME, OBJECT_NAME, POLICY_COLUMN, ENABLED, AUDIT_TRAIL FROM DBA_AUDIT_POLICIES; Querying Audit Trail Entries You can query the DBA_FGA_AUDIT_TRAIL data dictionary view to view the audit trail entries in a database. To query the DBA_FGA_AUDIT_TRAIL data dictionary view, type the following statement at the SQL prompt: SELECT DB_USER, TIMESTAMP, USERHOST FROM DBA_FGA_AUDIT_TRAIL;
98 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Managing Users and Securing Databases: Oracle 10g Administration I Describe how to create and manage user accounts. Describe how to grant and revoke privileges. Describe how to create and manage roles. Describe how to control resource usage. Learn how to apply the principle of least privilege. Describe how to manage default user accounts. Discuss how to implement standard password security features. Identify how to audit database activities.
99 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Working with Oracle Net Services: Oracle 10g Administration I
100 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Working with Oracle Net Services Scope •
Learn about the various features of Oracle Net Services.
Focused Explanation Introducing Oracle Net Services Oracle Net Services is a feature of Oracle that is used to transfer information over an Oracle network. Oracle Net Services supports various middleware products, such as Oracle Application Server and Oracle Connection Manager. You can use these middleware products to efficiently transfer information in an Oracle network. An Oracle network contains several Oracle database servers and their clients. Oracle Net Services provides distributed database and distributed processing for transferring information in an Oracle network by using communication protocols and Application Programming Interfaces (APIs). A communication protocol includes a set of rules for determining the access provided to an application and for transmission of data across the Oracle network. An API includes a set of subroutines for establishing remote communication between processes by using a communication protocol. Oracle Net Services transfers information in a network in the following manner: •
Oracle Net Services enables a network session between an application running on a client computer and an Oracle database server.
•
The Oracle database server and the clients use this network session to exchange information.
Features of Oracle Net Services The following are the various features of Oracle Net Services: •
Provides database connectivity
•
Manages the components of an Oracle network
•
Provides scalability
•
Provides security
•
Ensures accessibility
Providing Database Connectivity Database connectivity refers to the capability of an Oracle database to connect to the clients on a network through an application or the Internet. Oracle Net Services provides the following features to enhance database connectivity:
101 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Support for multiple protocols – Supports various enterprise network protocols, such as Named Pipes and Transfer Control Protocol/Internet Protocol (TCP/IP). These protocols enable Oracle Net Services to connect to multiple computers and operating systems simultaneously.
•
Support for multiple operating systems – Supports several platforms, such as Windows XP, UNIX, and mainframe-based operating systems. As a result, you can exchange information among clients on different platforms.
•
Support for Java and Java Database Connectivity (JDBC) – Supports JDBC drivers that enable Java applications to connect to an Oracle server. JDBC drivers act as an interface to connect to an Oracle database server, by using Oracle Net Services.
Managing Components of an Oracle Network Oracle Net Services enables you to manage the components of an Oracle network, such as Oracle database servers and their clients. Oracle Net Services supports the following features to manage the components of an Oracle network: •
Support for Web applications – Provides connectivity to an Oracle service, such as Oracle Enterprise Manager, by using a Web browser. Oracle Net Services can also use a middle-tier component, such as a Web application server, to connect to an Oracle server. You can also use Oracle Net Services to enable a client to directly connect to Oracle. For example, a Java applet executing on a Web browser connects to an Oracle server by using a JDBC driver, without using a Web server.
•
Support for location transparency – Hides the process of establishing a connection between a client and the Oracle database server. The technique of hiding the process of establishing connection is known as location transparency. In location transparency, the management of connection issues, such as type and location of network connectivity, is provided by Oracle Net Services. As a result, location transparency optimizes the use of resources in the Oracle database server.
•
Support for directory naming – Enables you to resolve names of Oracle services by using a technique called directory naming. Directory naming uses a centralized naming repository, such as Lightweight Directory Access Protocol (LDAP), to store, identify, and retrieve the names of Oracle services.
Scalability Scalability refers to the ability of an Oracle network to support increasing number of users and growing size of databases of an enterprise system. Oracle Net Services provides services, such as Oracle Shared Server and Oracle Connection Manager, which enable you to enhance the scalability of the Oracle network. Oracle Shared Server is an optional configuration of Oracle server that enables sharing of Oracle network resources among the users. It facilitates a large number of concurrent connections without increasing the resource requirements. Oracle Connection Manager is a middleware component that manages the communication between clients and servers in an Oracle network. It supports the following additional scalability features:
102 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Reduces the total number of network connections by multiplexing the network connections in a single network connection.
•
Restricts access of network resources from computers that want to communicate with an Oracle network, by using IP addresses. You can create rules to accept or reject client connection requests by applying restrictions at the destination server, Oracle server, or at the origin of the connection requests.
Security Oracle Net Services provides a secure network environment to perform business transactions in an organization. Oracle Net Services provides two security options, Advanced Security Option and Advanced Networking Option, which are also referred to as Oracle Advanced Security4 options. These security options provide techniques, such as using an identification PIN number, fingerprint, public key, and certificate, for authenticating users in an Oracle enterprise. You can use these techniques for granting access to computers on an Oracle network and for authenticating user connection requests to an Oracle server. Oracle Advanced Security options ensure the secure transmission of information across the Oracle network. It facilitates the secure transmission of information present in a transaction. Oracle Advanced Security provides secure transmission by using algorithms, such as RSA RC4, Standard DES, and Triple DES. These algorithms are used to encrypt the information transmitted across an Oracle network. This ensures that data is not modified while transmitting to the Oracle server. Oracle Advanced Security also provides a single sign-on mechanism that enables the users in an enterprise to connect to any Oracle service by using the same user name and password. Oracle Net Services also provides the Oracle Net Application Proxy Kit. This kit is incorporated into a firewall to ensure the security of database information that passes through a firewall in an Oracle network. Note: A firewall is a security mechanism that handles incoming and outgoing network traffic and prevents malicious users from violating the security of network. Accessibility Accessibility refers to the ability to provide communication across different computers and databases. Oracle Net Services provides products and services, such as Oracle Transparent Gateway and Generic Connectivity, for establishing communication with non-Oracle databases, such as SQL Server and MySQL. Oracle Net Services also enables you to call the external procedures written in a third-generation programming language, such as C, Java, and C++, by invoking them from Oracle PL/SQL callouts. A process named extroc is initiated that forms an interface between Oracle and external procedures. The extroc process provides information, such as name and parameters of the procedures, to the called external procedures. The extroc process loads and controls the execution of external procedures. Note: An external procedure refers to an external subprogram written in a third-generation programming language, such as C.
103 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Managing Oracle Listeners and Configuring Oracle Net Services on Oracle Server Scope •
Define Oracle listeners.
•
Learn how to configure Oracle Net Services on the Oracle 10g Server.
•
Configure connect-time failure.
Focused Explanation Introducing Oracle Listeners An Oracle listener is a server-side networking component that listens for connection requests and establishes connections between client computers and an Oracle server. A listener can listen to multiple databases configured on an Oracle server. A client can initiate a connection from a remote location or from the computer on which the listener is running. The response of a listener to a client request depends on the configuration of server-side network components and the type of connection requested by the client. A default listener, LISTENER, is created when you install Oracle. The LISTENER listener is executed either on a middle-tier server or on a database server. You can use Oracle Real Application Clusters (RAC) to configure multiple listeners on a server. RAC is a computing environment that uses the processing power of multiple, interconnected computers on a network. The presence of multiple listeners on a single server reduces the load of multiple connections on a single listener, and provides fault tolerance to the Oracle server. Note: If there are multiple listeners configured on an Oracle server, each listener has a unique name. Structure of the listner.ora File The listener.ora file is a centralized file that controls the listeners. There can be multiple listeners on an Oracle server, but there is a single listener.ora file configured on the server. The listener.ora file contains the configuration information for all the listeners.
104 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following is the structure of the listener.ora file: # listener.ora Network Configuration File: # Generated by Oracle Configuration tools D:\oracle10g\NETWORK\ADMIN\SAMPLE\listener.ora SID_LIST_LISTENER=(SID_LIST=(SID_DESC= # #BEQUEATH CONFIG # (GLOBAL_DBNAME=salesdb.mycompany) # (SID_NAME=sid1) # (ORACLE_HOME=/private/app/oracle/product/8.0.3) # #PRESPAWN CONFIG # (PRESPAWN_MAX=20)s # (PRESPAWN_LIST= # (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))))) Table 6-1 shows the default settings of the listener.ora file.
Section Name in the listener.ora File
Setting
Name of listener
LISTENER
Port
1521
Protocols
TCP/IP and IPC
Name of host
Default Host Name
Name of SID
Default Instance Table 6-1: Default Settings of the listener.ora File
Creating and Managing Oracle Listeners Oracle provides three tools that you can use to create and manage Oracle listeners. These are: •
Oracle Net Manager
•
Oracle Enterprise Manager
•
The LSNRCTL command-line utility
Using Oracle Net Manager Oracle Net Manager is a tool that enables you to create and manage client-side and server-side network configuration files. You can also create listeners and add services to listeners using Oracle Net Manager.
105 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Creating a Listener using Oracle Net Manager To create an Oracle listener using Oracle Net Manager, complete the following steps: 1. Click Start -> Programs -> OracleOraDb10ghome4 -> Configuration and Migration Tools -> Net Manager. The opening screen of Oracle Net Manager is displayed. Figure 6-1 shows the opening screen of Oracle Net Manager.
Figure 6-1: The Oracle Net Manager Opening Screen 2. Expand the Local folder and click the Listeners icon. Expand the Listeners folder or click Edit Æ Create. The Choose Listener Name dialog box is displayed. 3. Type the name of the listener in the Listener Name text box of the Choose Listener Name dialog box. If the default listener already exists, the Net Manager displays the default listener name as LISTENER or LISTENER1 in the Listener Name text box. 4. Click OK to continue. The Listening Locations screen is displayed.
106 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
5. Click the Listening Locations drop-down list and select the required option to configure the listening locations. 6. Click the Add Address button at the bottom of the Listening Locations screen. The Network Address screen is displayed. Figure 6-2 shows the Network Address screen.
Figure 6-2: The Network Address Screen The following are the options on the Network Address screen: Protocol – Specifies the protocol of the Oracle server. The default protocol is TCP/IP. Host – Specifies the name of the host computer. Port – Specifies the port number on which the listener is running.
107 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
7. Accept the default settings and click File -> Save Network Configuration to create the listener. Note: You can determine the location of files by examining the title bar of the Oracle Net Manager screen. Adding a Service Name to the Listener A service is a program that a listener executes as a background process in the Windows environment. You must add a service name to the listener if you want to call and execute the service. You can define the services to which a listener can connect by specifying the name, protocol, port, and host information for the service. This process is referred to as static service registration because you need to implicitly register a service with the listener. You can add multiple service names to a listener. To add a service name to a listener, complete the following steps: 1. Expand the Listener folder on the opening screen of Oracle Net Manager and select the name of the listener you want to configure. 2. Select the Database Services option from the Listening Locations drop-down list. 3. Click the Add Database button at the bottom of the Listening Locations screen. The Database Services screen is displayed.
108 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 6-3 shows the Database Services screen.
Figure 6-3: The Database Services Screen The Database Services screen contains the following text boxes: Global Database Name – Contains the fully-qualified name of the Oracle database. Oracle Home Directory – Contains the location of the directory where Oracle is installed. SID – Contains a unique name of the database instance. 4. Accept the default settings and click File -> Save. This saves the service name information for the listener at the specified location.
109 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Using Oracle Enterprise Manager to Manage Listeners You can also use Oracle Enterprise Manager to manage Oracle Net Services. To manage a listener using Oracle Enterprise Manager, complete the following steps: 1. Type the http://hostname:5500/em URL in a Web browser. The Oracle Enterprise Manager page is displayed. 2. Type the User Name as sys, Password as oracle, and select the sysDBA option from the Connect As drop-down list to login as the SYS user. This enables you to perform administrative functions, such as creating a listener. 3. Click Login to Continue. The Database: oracle page of Oracle Enterprise Manager is displayed. Figure 6-4 shows the Database: oracle page.
Figure 6-4: The Database: oracle Page
110 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
4. Click the LISTENER_rd02 link in the General pane. The Serviced Databases page is displayed. This page displays information, such as location and net address of the listener. It also displays various links present in the Related Links pane. 5. Click the Net Services Administration option in the Related Links pane. The Net Services Administration page is displayed. This page displays the information about configuration file location that can be used for network administration, such as the name of a net service. 6. Select the Listeners option from the Administer drop-down list and click Go. The Listeners page is displayed. This page displays information, such as protocol details, status, and Enterprise Manager target for existing listeners. 7. Click the Create button. The Create Listener page is displayed. 8. Accept the default name as LISTENER0 in the Listener Name text box and click Add to continue. The Add Address page is displayed. This page displays the default values as TCP/IP in the Protocol drop-down list and the name of the host computer in the Host text box. Type the port number as 1522 in the Port text box. 9. Click OK to continue. The Create Listener page is displayed again.
111 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 6-5 shows the Create Listener page.
Figure 6-5: The Create Listener Page 10. Click OK to save the information. The Creation Message page is displayed. This page displays the listener, LISTENER0. You can select the Start/Stop option from the Actions drop-down list in the Creation Message page. This action stops a running listener or starts one that is not running. Modifying Existing Listeners Using Oracle Enterprise Manager You can also modify existing listeners by using Oracle Enterprise Manager. Editing an existing listener modifies the parameters in the listener.ora file and saves the modified information in the same file. To edit an existing listener, complete the following steps: 1. Open the Creation Message page of Oracle Enterprise Manager and click the Edit button. The Edit Listener page is displayed. This page displays the protocol used to create the listener and the listener's details, such as Host and Port, with corresponding values of name of the host computer and port number of the listener, respectively.
112 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
2. Click Edit to continue. The Edit Address: TCP/IP page is displayed. This page enables you to modify the Host and Port values associated with the listener. 3. Click OK to save the modified information. Managing Listeners Using the LSNRCTL Utility You can also manage listeners by using the LSNRCTL command-line tool. You must type the LSNRCTL command at the command prompt to invoke the command-line utility. You can perform several tasks using the LSNRCTL utility. Some of the important tasks are: •
Starting a listener – Type start at the LSNRCTL prompt to start the default listener. You must type start followed by the listener name, if you want to start a different listener.
•
Reloading a listener – Type reload followed by the listener name at the LSNRCTL prompt to update the listener information. If you do not type the listener name after typing reload, the default listener is reloaded. You need to reload a listener by using Oracle Net Manager or Oracle Enterprise Manager, if you have modified the parameters in the listener.ora file manually. There is no need to stop and start the listener before executing the reload command. However, you can use the reload command as an alternative for stopping and starting the listener, to refresh the contents of the listener.
•
Displaying the status of a listener – Type status followed by the listener name at the LSNRCTL prompt to display the status of a listener. If you do not type the listener name after typing status, the status of the default listener is displayed. The status command displays information, such as location of log files, services associated with the listener, and the time from which the listener has been executing.
•
Displaying the services for a listener – Type services followed by the listener name at the LSNRCTL prompt to display the services associated with a listener. If you do not type the listener name after typing services, the services associated with the default listener are displayed. The information displayed includes the number of connections that are accepted or rejected per service, and whether the services have dispatched or dedicated processes associated with a listener.
•
Stopping a listener – Type stop followed by the listener name at the LSNRCTL prompt to stop the executing listener. If you do not type the listener name after typing stop, the default listener stops executing.
•
Changing the password – Type change_password followed by the listener name at the LSNRCTL prompt to change a password required for stopping the executing listener. If you do not type the listener name after typing change_password, the password for the default listener is changed.
113 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Additional Configurations for Using Multiple Listeners When multiple listeners service your database connection requests, you need to use additional configuration features for using multiple listeners. The following are the additional configuration features: •
Connect-time failover
•
Transparent application failover
•
Connection load balancing
Connect-Time Failover A connect-time failure occurs when the initial connection to the first listener fails. The connect-time failover feature enables a client to connect to another listener if the initial connection fails. The tnsnames.ora file specifies the location of multiple listeners. A connection request to the next listener in the list is attempted, if a connection attempt to the first listener fails. This feature enhances the availability of Oracle services. The following is the structure of the tnsnames.ora file when the connect-time failover feature is enabled: ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS=(PROTOCOL=TCP) (HOST=DBPROD)(PORT=1521) (ADDRESS=(PROTOCOL=TCP) (HOST=DBFAIL)(PORT=1521) ) (CONNECT_DATA=(SERVICE_NAME=PROD)(SERVER=DEDICATED) ) ) The ADDRESS_LIST section specifies an additional listener. When a connection fails when attempting to connect to the DBPROD host on port 1521, a connection attempt is made to connect to the DBFAIL host on port 1521. Transparent Application Failover Transparent Application Failover (TAF) is a feature that ensures automatic re-establishment of connection between a client and Oracle service, if the current connection between them fails. This feature is used in an Oracle network where high availability of Oracle services is required. If a client connection to the database fails, TAF enables a client application to automatically reconnect to the database. Connection Load Balancing Oracle Net Services enables you to use client load balancing, which enables a client to randomly select a listener from the available list of listeners. It balances the load of connection requests among available listeners. Connection load balancing efficiently distributes connections among dispatchers in an Oracle Shared Server environment.
114 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Troubleshooting Connection Problems at the Server-Side You may need to troubleshoot the server-side connection problems, even if you have configured serverside components correctly. Some of the reasons for connection problems include: •
The Oracle server, middle-tier, or client is not configured correctly.
•
The client is unable to resolve the name of the net service associated with a listener.
•
The network protocol, such as TCP/IP, is not active on the server.
•
The user types an invalid username, password, or net service name.
You can identify and resolve these errors by performing server-side computer and database checks. Before executing these checks, you must ensure that the computer on which the Oracle server is configured is running properly and the listener is active. The various server-side computer and database checks include: •
Verifying the server computer: Ensure that the server computer is running properly and is available for accepting new connections. However, a few computers allow only administrators to access the computer. Therefore, you need to ensure that the computer is available to all users. In a TCP/IP network, you can use the ping utility on a client computer to verify connectivity to the server.
•
Verifying the database is running: Connect to the Oracle server and log on to the database using SQL*Plus to verify whether or not the database is running. You can first attempt to create a local connection that does not use an Oracle listener. For this, you need to set the ORACLE_SID environment variable to the name of the Oracle instance, and then connect to SQL*Plus. You can type the sqlplus system/manager command at the command prompt to verify the database connectivity. When connecting to SQL*Plus if an ORA-01034 error occurs, it indicates that the Oracle instance is not running and that you need to start the Oracle instance. The ORA-27101 error indicates that no instance is presently available for connecting to the ORACLE_SID environment variable.
•
Verifying the database is open to users: Ensure that the database is not opened in a restricted mode. When a database is opened in a restricted mode, unprivileged users will not be allowed to connect to the Oracle server. You can type the sqlplus scott/tiger@ORCL command at the command prompt to verify whether or not the database is open to users. The ORA-01035 error indicates that the Oracle server is only available to users with RESTRICTED SESSION privilege.
•
Verifying the user privileges: Ensure that the user has been granted the CREATE SESSION privilege to establish the connection to the Oracle server.
115 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
After performing the server-side computer and database checks, you need to perform the server-side network checks. The various server-side network checks include: •
Verifying the listener: Ensure that the listener and its associated services are running on the Oracle server. You can type the lsnrctl status command to verify the status of the default listener, LISTENER, and the services associated with the listener.
•
Verifying listener protocols: Ensure that the protocol used by the client is the same as the protocol used by the service requesting a connection. You can type the lsnrctl services command at the command prompt to accomplish this. The ORA-12541:“No Listener” error message indicates that the client is requesting to connect using a protocol for which a listener is not listening.
•
Verifying server protocols: Ensure that the network protocol on the server is active. You can use the ping command at the command prompt to accomplish this.
•
Verifying connection timeouts: Ensure that the client is not timing out before establishing a valid connection. The ORA-12535 or ORA-12547 error indicates a connection timeout, which can occur in the case of slow network connections. You can set a higher value for the INBOUND_CONNECT_TIMEOUT parameter so that the listener will wait longer for a valid response from the client.
116 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Configuring Client and Middle-tier Connection Scope •
Learn about various service name resolution methods for configuring client and middle-tier connections.
Focused Explanation Configuring Client and Middle-tier Connections After configuring the Oracle server, you need to configure clients and middle-tier connections to access the resources from the Oracle server. For this, you need to identify the network requirements of an organization, type of connectivity, and the number of client/server connections before configuring clients. A client needs to provide a username, password, and net service name to connect to an Oracle server. The net service name provides the path of the Oracle server and the services associated with it in the form of a connect descriptor. The path depends on the name resolution method selected by a client. The various net service name resolution methods are: •
Oracle Internet Directory
•
External naming
•
Host naming
•
Oracle easy connect
•
Local naming
You use the Oracle Internet Directory method when a network contains multiple Oracle servers. This method enables you to manage net service names and store connect descriptor information at a central location. When an organization uses the external name resolution method, such as Network Information Service (NIS), it stores the database service information at an external location. In this situation, you need to use a non-Oracle facility named external naming to manage and resolve Oracle service names. You use the host naming method when a network contains only a few Oracle servers. You use the host naming method in a TCP/IP network environment in which a client is provided with an external naming service, such as DNS or a HOSTS file. Oracle uses the host naming method when a client fails to connect using the local naming method. However, you can override the default search path for resolving names. You need to configure the NAMES.DIRECTORY_PATH parameter in the sqlnet.ora file on the clientside by using Oracle Net Manager so that it searches only for host naming. However, you can also use the host naming method, if you have multiple Oracle servers on the same computer. For this, there needs to be a separate entry for each Oracle service in the external naming service resolution method. The Oracle easy connect naming method is similar to the host naming method. However, this method allows you to type the port and service name specification, in addition to the parameters required by host
117 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
naming method. The Oracle easy connect naming method is configured by default on a computer when you install Oracle Net. This method addresses the limitation of the host naming method that listens on a default port of 1521. To use the Oracle easy connect method, the client needs to install Oracle Net Services on the computer. Both the client and server need to support the Oracle Net TCP/IP services. The local naming method uses the tnsnames.ora file to resolve net service names. This method is also referred to as tnsnames.ora method. You need to configure the tnsnames.ora file to use the local naming method. The default location for the tnsnames.ora file is %ORACLE_HOME%\network\admin in Windows and $ORACLE_HOME/network/admin in UNIX systems. You need to set the TNS_ADMIN environment variable, if you want to modify the location of tnsnames.ora file. However, you need to export the TNS_ADMIN environment variable in the user’s profile or user’s shell environment for UNIX systems. To configure the local naming method, you can also store the tnsnames.ora file at the default location on the client and server computers. However, the default locations for the tnsnames.ora file on client and server computers are the same. You can also centrally manage the tnsnames.ora file by storing it in a shared location.
118 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Oracle 10g Administration 1: Working with Oracle Net Services Learn about the various features of Oracle Net Services Learn about Oracle listeners. Learn how to configure Oracle Net Services on the Oracle 10g server. Configure connect-time failure. Learn about various service name resolution methods for configuring client and middle-tier connections.
119 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Working with Oracle Shared Server: Oracle 10g Administration I
120 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Specifying the Need and Architecture of Shared Server Scope •
Describe the need for Oracle Shared Server.
•
Define the architecture of Oracle Shared Server.
Focused Explanation Need for Oracle Shared Server When the number of users connected to an Oracle database in an organization increases, server requirements, such as memory and process requirements also increase. Oracle Shared Server is used to meet the memory and process requirements of the servers. The configuration of Oracle Shared Server avoids frequent system upgrades, which occur due to an increase in the number of users. Oracle Shared Server can establish a large number of concurrent connections without increasing any resource requirements. Oracle Shared Server establishes these concurrent connections by sharing resources among users. A dedicated server associates a dedicated process for every client connection on an Oracle server machine. This dedicated process is also referred to as the shadow process. The dedicated server process is responsible for processing requests of only the client to which it is associated. Table 7-1 lists the differences between Oracle Shared Server and Oracle Dedicated Server.
Oracle Shared Server Handles processing requests from multiple clients. Supports the same or a greater number of connections without requiring any additional resources, such as memory. Supports connection pooling to handle a large number of requests without starting additional dispatcher processes. Cannot perform startup and shutdown functions Does not perform administrative tasks, such as handling bulk data and table analysis.
Oracle Dedicated Server Processes only a single client request at a time. Supports all the client requests using a single dedicated server process. Works efficiently by decreasing the response time to the clients when the network traffic is high. Can perform startup and shutdown functions. Performs administrative tasks, such as handling bulk data and table analysis.
Table 7-1: Differences between Oracle Shared Server and Dedicated Server Oracle Shared Server Architecture In Oracle Shared Server architecture, certain modifications take place in its internal memory structure. These modifications take place when we migrate from a dedicated server to Oracle Shared Server. The changes in the internal memory structure are based on the changes in the System Global Area (SGA) and Program Global Area (PGA) memory segments.
121 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
An SGA memory segment contains two types of structures, a request queue and a dispatcher response queue. The Oracle Shared Server contains a single request queue for all dispatchers, but separate response queues for each dispatcher. The Shared Server executes each request in the request queue and places it in the response queue of the dispatcher. All the information about each client session is maintained in the PGA segments. The information in the PGA includes bind variables, cursor information, and the client’s sort area. This information from the PGA memory segments is transferred to the User Global Area (UGA), which is a segment of the SGA. Figure 7-1 shows how the SGA and PGA structures differ between a dedicated server and an Oracle Shared Server environment.
Figure 7-1: SGA and PGA Structures in a Dedicated Server versus Oracle Shared Server Environment
122 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Configuring Oracle Shared Server Scope •
Describe Oracle Shared Server parameters and Oracle Shared Server configuration using Database Configuration Assistant and Enterprise Manager.
Focused Explanation Shared Server Parameters Oracle Shared Server is configured by adding and modifying parameter values in the Oracle initialization parameter file. The Oracle Shared Server parameters identify the number of shared servers, number and type of dispatchers, and name of the databases that are associated with the Oracle Shared Server. All the parameters in Oracle 10g that are necessary to manage Oracle Shared Server can be changed at run-time to make the database available. The following parameters are used to manage Oracle Shared Server: •
DISPATCHERS
•
MAX_DISPATCHERS
•
SHARED_SERVER_SESSIONS
•
MAX_SHARED_SERVERS
•
CIRCUITS
The DISPATCHERS Parameter The DISPATCHERS parameter defines the number of dispatchers that are initiated when an Oracle instance is started. The DISPATCHERS parameter also specifies the type of protocol to which the dispatcher can respond.
123 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Table 7-2 lists the attributes of the DISPATCHERS parameter: Attribute ADDRESS
Abbreviations ADD or ADDR
CONNECTIONS
CON or CONN
DESCRIPTION
DES or DESC
DISPATCHERS
DIS or DISP
LISTENER
LIS or LIST
PROTOCOL
PRO or PROT
SESSIONS
SES or SESS
SERVICE
SER or SERV
POOL
POO
Description Specifies the network protocol address of the end point of the dispatcher. Defines the maximum number of network connections for each dispatcher. Describes the endpoint of the network, where the dispatcher is listening for the Oracle services. It describes the protocol being used for listening. Defines the number of dispatchers that are initiated when an instance is started. The number of dispatchers depends on the configuration of the operating system. The default value for the number of dispatchers is 1. Defines the address of the listener to which the PMON process sends the connection information. Specifies the network protocol used by the dispatcher for listening. Describes the maximum number of network sessions allowed for each dispatcher. Defines the name of the Oracle Net Service that the dispatcher registers with the listener. Describes connection pooling for handling a large number of connections.
Table 7-2: Summary of Attributes of the DISPATCHERS Parameter The MAX_DISPATCHERS Parameter The MAX_DISPATCHERS parameter sets the maximum number of dispatchers for the Oracle Shared Server. In Oracle10g, the ALTER SYSTEM statement is used to set the MAX_DISPATCHERS parameter at run-time. The maximum number of processes that the dispatcher can run concurrently depends on the configuration of the operating system. The formula used to set the MAX_DISPATCHERS parameter is MAX_DISPATCHERS = (maximum number of concurrent sessions/connections per dispatcher). For example, you can specify that Oracle Shared Server can start eight dispatchers at a time by setting the MAX_DISPATCHERS parameter to 8 using this statement: ALTER SYSTEM SET MAX_DISPATCHERS=8; The SHARED_SERVER_SESSIONS Parameter The SHARED_SERVER_SESSIONS parameter specifies the total number of Oracle Shared Server sessions you can use in an Oracle instance.
124 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
When the number of Oracle Shared Server client connections exceeds the limit, a client attempting to connect receives the following error message: ERROR: ORA-00018 maximum number of sessions exceeded. You can limit the number of shared server sessions using the SHARED_SERVER_SESSIONS parameter. You can set the SHARED_SERVER_SESSIONS parameter in the Oracle initialization file or modify the parameter using the ALTER SYSTEM statement. The MAX_SHARED_SERVERS Parameter The MAX_SHARED_SERVERS parameter sets the maximum number of Oracle Shared Servers that can run simultaneously. You can modify the MAX_SHARED_SERVERS parameter using the ALTER SYSTEM statement. If no value is specified for the MAX_SHARED_SERVERS parameter, then any number of Oracle Shared Servers can be started simultaneously. The CIRCUITS Parameter The CIRCUITS parameter manages the total number of virtual circuits for all incoming and outgoing network sessions. The CIRCUITS parameter affects the total size of the SGA at system startup. Therefore, there is no default value for this parameter. You can configure this parameter manually to limit the number of virtual circuits. You can modify the CIRCUITS parameter using the ALTER SYSTEM statement. Configuring Shared Server using Database Configuration Assistant Oracle Shared Server is configured when a database is created using the Database Configuration Assistant (DBCA). To configure Oracle Shared Server using DBCA, perform the following steps: 1. Select the Connection Mode tab on the DBCA Initialization Parameters screen. 2. Select the Shared Server Mode option on the Initialization Parameters screen. 3. Type the number of server processes in the Shared Server text box. This Shared Server text box specifies the number of server processes that you want to create when an instance is started.
125 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 7-2 shows the Initialization Parameters screen of DBCA.
Figure 7-2: Initialization Parameters Screen 4. Click the Edit Shared Server Parameters button on the Connection Mode tab to change the maximum number of Oracle Shared Servers and dispatchers, and the number of dispatchers started at instance startup. 5. Click the General tab on the Edit Shared Server Parameters screen to modify the default value and choose a new value for the maximum number of shared servers and dispatchers. 6. Click the Dispatcher tab on the Edit Shared Server Parameters screen to configure the other attributes, such as the SESSION, CONNECTION, LISTENER, and SERVICE attributes. 7. Click the Advanced Options button on the Dispatcher tab on the Edit Shared Server Parameters screen to set up the advanced attributes of the DISPATCHERS parameter, such as multiplexing and connection pooling.
126 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Configuring Shared Server using Enterprise Manager You can configure Oracle Shared Server using Enterprise Manager, which is a Web-based GUI tool for managing the Oracle environment. To configure Oracle Shared Server using Enterprise Manager, perform the following steps: 1. Open Enterprise Manager Database Control using the Web browser. 2. Click the Administration tab to connect to the Enterprise Manager Database Control. The Administration tab page is displayed. 3. Click the All Initialization Parameters link in the Instance category of the Administration tab page. The Initialization Parameters page is displayed. Figure 7-3 shows the Initialization Parameters page.
Figure 7-3: The Initialization Parameters Page 4. Click the Show All button on the Initialization Parameters page to display and modify the desired initialization parameters. All initialization parameters are displayed on the Initialization Parameters page. 5. Type the partial or full name of the parameter that you want to modify in the Filter text box of the Initialization Parameters page and click Go. All the parameters that match the name specified in the Filter text box are displayed on the Initialization Parameters page. 6. Type the new value for the parameter in the Value field.
127 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
7. Save the changes to the parameter values. The following are the ways to save the changes in the parameter value: a. Click the Apply button on the Initialization Parameters page to make all the changes effective at run-time. b. Click the Save To File button on the Initialization Parameters page to save the changes in the existing parameter file. The changes in parameter values will be effective for the next startup of the database instance. c.
Make the new changes in the parameter initialization file and save this file. The changes in parameter values will be effective for the next startup of the database instance.
Note: The ALTER SYSTEM statement enables you to configure the Oracle Shared Server parameters without starting and stopping the server.
128 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Monitoring Oracle Shared Server Scope •
Describe how to manage Oracle Shared Server using the listener utility and dynamic views.
•
Identify the steps necessary to tune Oracle Shared Server.
Focused Explanation Managing Oracle Shared Server You can manage the Oracle Shared Server using the listener utility and various dynamic views. To manage the Oracle Shared Server, it is necessary to know how to view the information about the Oracle Shared Server. Therefore, Oracle provides the listener utility to collect information about the Oracle Shared Server connections. Displaying Information Using the Listener Utility The lsnrctl command-line listener utility is used to display the information about the dispatcher processes. The listener utility traces all the information about the current connection load for all the dispatchers. To view information about dispatchers, you use the lsnctrl services command at the command prompt. Oracle also provides dynamic performance views to gather information about the Oracle Shared Server configuration and performance. Displaying Information Using Dynamic Performance Views Oracle offers dynamic performance views, which provide system performance information about Oracle Shared Server. The dynamic performance views are also referred to as V$ views. These views contain information about the number of dispatchers, activity among shared servers, and activity in the request and response queues. The dynamic performance views also provide information about the clients that are connected via shared server connections. The various dynamic performance views used to obtain information about Oracle Shared Server are: •
V$DISPATCHER – Contains information about dispatcher activity and the number of connections that are currently being handled by each dispatcher. The V$DISPATCHER dictionary view also provides the information about the total number of connections that each dispatcher has handled since startup.
•
V$DISPATCHER_CONFIG – Contains configuration information about each dispatcher, such as the protocol and the listener address of the dispatcher. This view also contains information about the service names for connections and sessions.
•
V$DISPATCHER_RATE – Displays statistics for the dispatchers, such as the maximum number of inbound and outbound connections and the average rate of bytes processed per client connection.
129 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
V$QUEUE – Contains information about the request and response queues, such as waiting time of requests in the queue.
•
V$CIRCUIT – Displays information about Oracle Shared Server virtual circuits, such as the current status of the client connection and the amount of information exchanged between the client and the dispatcher.
•
V$SHARED_SERVER – Contains information about the shared server processes, such as the number of requests and the information processed by the shared servers.
•
V$SHARED_SERVER_MONITER – Contains information that helps in tuning the Oracle Shared Server. The V$SHARED_SERVER_MONITER view includes the information about the maximum number of concurrent connections and the total number of servers started since startup.
•
V$SESSION – Contains information about client sessions, such as user name, session status, client session address and the operating system user name.
Tuning the Shared Server You need to examine the performance of the dispatcher and the shared server processes before tuning the Oracle Shared Server. You need to ensure that there are enough dispatchers to respond to the client requests. For tuning the shared server, many shared server processes should be provided to process client requests. You need to configure the Large Pool SGA memory area to store the information for a dedicated server. The Large Pool enhances the performance of the memory area of the Shared Pool. To tune the shared server, you need to perform the following tasks: •
Configure the Large Pool.
•
Set the Large Pool to an appropriate size.
•
Monitor the performance of the dispatcher and shared servers.
Configuring the Large Pool You can set the LARGE_POOL_SIZE parameter in the init.ora file to configure the Large Pool. The value of the LARGE_POOL_SIZE parameter ranges from 300 KB to 2 GB. By default, Oracle sets the value of the LARGE_POOL_SIZE parameter to 250 KB per session for each shared server when specifying the DISPATCHER parameter. If a Large Pool is not configured, Oracle places the UGA in the Shared Pool, which affects the performance of the Shared Pool. For example, you can set the LARGE_POOL_SIZE parameter in the init.ora file as 100M using this entry: LARGE_POOL_SIZE=100M
130 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
To modify the LARGE_POOL_SIZE parameter at run-time, you need to use the ALTER SYSTEM statement. For example: ALTER SYSTEM SET LARGE_POOL_SIZE=50M; Setting the Large Pool to an Appropriate Size Each shared server connection in the Large Pool needs memory between 1 MB and 3 MB. The Large Pool should be large enough to store information for all the shared server connections. The V$SESSTAT view enables you to determine the memory space used by the shared server connections. The V$SESSTAT view also contains information about the memory used per user. A client encounters a connection error if the size of the Large Pool area is too small. If the value of the LARGE_POOL_SIZE parameter is less than the required size, then you can modify the LARGE_POOL_SIZE parameter using the ALTER SYSTEM statement. Monitoring the Performance of the Dispatcher and Shared Servers To monitor the performance of the dispatchers and the shared servers, you should perform the following tasks: •
Determine the number of dispatchers and shared servers.
•
Measure the wait time for dispatchers.
Determining the Number of Dispatchers and Shared Servers The V$DISPATCHER view displays information about the dispatcher processes. You can use this view to determine whether or not it would be advantageous to initiate more dispatcher processes. For example, the following query calculates the percentage of time for which a dispatcher is busy: SELECT name,(busy/(busy+idle))*100 "Dispatcher % busy Rate" FROM V$DISPATCHER; The V$SHARED_SERVER and V$QUEUE dictionary views are used to monitor shared servers. The shared servers execute client requests and place the client requests in the appropriate dispatcher response queue. For example, the following query shows how long the client requests are waiting in the request queue: SELECT DECODE(totalq,0,'No Requests') "Wait Time", Wait/totalq || 'hundredths of seconds' "Average Wait time per request" FROM V$QUEUE WHERE type='COMMON';
131 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Measuring the Wait Time for Dispatchers You can use the V$DISPATCHER and V$QUEUE views to determine the time taken by the dispatcher to execute a request. For example, the following query shows the average waiting time for the dispatcher: SELECT DECODE(SUM(totalq),0,'No Responses', SUM(wait)/SUM(totalq) "Average Wait Time" FROM V$QUEUE q, V$DISPATCHER d WHERE q.type='DISPATCHER' AND q.paddr=d.paddr;
132 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Working with Oracle Shared Server: Oracle 10g Administration I Describe the need for Oracle Shared Server. Describe the architecture of Oracle Shared Server. Describe the various parameters of Oracle Shared Server. Describe the Oracle Shared Server configuration using DBCA. Describe the Oracle Shared Server configuration using Enterprise Manager. Describe how to manage Oracle Shared Server using the listener utility. Describe how to display the system performance information using dynamic performance views. Describe how to tune Oracle Shared Server. Describe how to configure the Large Pool size. Describe how to monitor the performance of dispatcher and shared servers.
133 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Performance Monitoring and Proactive Maintenance: Oracle 10g Administration I
134 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Performance Monitoring Scope •
Describe how to troubleshoot invalid and unusable objects.
•
Describe how to collect optimizer statistics in Oracle 10g.
•
Describe how to view performance metrics in Oracle 10g.
Focused Explanation Troubleshooting Invalid and Unusable Objects A database object, such as a procedure or function, which contains errors, is called an invalid object. An unusable object refers to a database object that is not enabled in a database. Invalid and unusable objects consume memory and server resources. To ensure consistent performance of the database, you should manage invalid and unusable objects in a database. Oracle 10g helps manage invalid and unusable objects by monitoring, identifying, and troubleshooting database performance issues related to invalid and unusable objects. You can use the DBA_OBJECTS data dictionary view in Oracle 10g to manage and troubleshoot invalid and unusable objects. The DBA_OBJECTS data dictionary view contains a STATUS column. The value of the STATUS column, either VALID or INVALID, represents the status of the database object. Tracking and Troubleshooting Invalid Objects Using Data Dictionary Views You can query the DBA_OBJECTS and DBA_INDEXES data dictionary views to track invalid objects. To track and troubleshoot invalid objects using data dictionary views, complete the following steps: 1. Identify the invalid objects using the data dictionary views. For example, the following statement shows how to query the DBA_OBJECTS view to identify the invalid objects: SQL> SELECT owner, object_name, object_type 2 FROM DBA_OBJECTS 3 WHERE status=‘INVALID’; 2. Manually correct the errors in the invalid objects by correcting the syntax errors in the invalid objects. 3. Compile the invalid objects. For example, execute the following statement to compile the p_update_sales_history invalid object: SQL> ALTER PROCEDURE sh.p_update_sales_history COMPILE;
135 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Tracking and Troubleshooting Unusable Objects Using Data Dictionary Views Data dictionary views, such as DBA_OBJECTS and DBA_INDEXES, also help you to track and troubleshoot unusable objects. To track and troubleshoot unusable objects using the DBA_INDEXES data dictionary view, complete the following steps: 1. Identify the unusable objects. For example, the following statement shows how to identify the unusable objects: SQL> SELECT owner, index_name, index_type 2 FROM DBA_INDEXES 3 WHERE status=‘UNUSABLE’; 2. Rebuild the unusable objects. For example, the following statement shows how to rebuild the job_id_pk index: SQL> ALTER INDEX
hr.job_id_pk REBUILD;
Tracking and Troubleshooting Invalid Objects Using Enterprise Manager The Enterprise Manager tool of Oracle 10g helps track and troubleshoot invalid objects. To track and troubleshoot invalid objects by using Enterprise Manager, complete the following steps: 1. Open the Database Control Home page of the Enterprise Manager. 2. Click the Administration tab to open the Administration tab page. 3. Click the Procedures link under the Schema pane of the Administration tab page. The Procedures page is displayed. 4. Type Scott in the Schema text box and click the Go button. The Procedures page is displayed again, which shows the status of the PROC1 procedure.
136 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 8-1 shows the Procedures page, which displays the status of the PROC1 procedure.
Figure 8-1: The Procedures Page of the Enterprise Manager 5. Select the Compile option from the Actions drop-down list, and click Go. The Edit Procedure: SCOTT.PROC1 page is displayed. 6. Correct the errors in the PROC1 procedure. You can make the necessary changes in the syntax of the procedure in the Source text field of the Edit Procedure: SCOTT.PROC1 page. 7. After correcting the syntax, click the Compile button at the bottom of the Edit Procedure: SCOTT.PROC1 page to compile the PROC1 procedure.
137 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The Edit Procedure: SCOTT.PROC1 page displays that the PROC1 procedure has been compiled successfully, as shown in Figure 8-2.
Figure 8-2: The Compiled PROC1 Procedure Tracking and Troubleshooting Unusable Objects Using Enterprise Manager To track and troubleshoot unusable objects using Enterprise Manager, complete the following steps: 1. Open the Administration tab page of the Enterprise Manger. 2. Click the Indexes link to open the Indexes page.
138 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 8-3 shows the Indexes page.
Figure 8-3: The Indexes Page 3. Select the Index Name option from the Search By drop-down list. Type SCOTT in the Schema text box, and click the Go button. The Indexes page is displayed again, which shows a list of all the indexes in the SCOTT schema. 4. Select the unusable index that you want to troubleshoot. Select the Reorganize option from the Actions drop-down list and click the Go button. The Reorganize Objects: Objects page is displayed.
Figure 8-4 shows the Reorganize Objects: Objects page.
139 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 8-4: The Reorganize Objects: Objects Page 5. Click Next to display the Reorganize Objects: Options page. 6. Click Next to display the Reorganize Objects: Impact Report page. 7. Click Next to display the Reorganize Objects: Schedule page. This page helps you to schedule the job to reorganize the unusable objects. 8. Type the user name and password of the host computer in the Username and Password text boxes on the Host Credentials pane, respectively. 9. Select the time when you want to reorganize the unusable objects, using the options in the Start pane. 10. Click Next to display the Reorganize Objects: Review page. Click the Submit Job button to rebuild the unusable object. Collecting Optimizer Statistics The data dictionary views store the statistics related to database performance. These statistics are called optimizer statistics. Optimizer statistics contain information about different database objects. For example, optimizer statistics for a table of a database includes information about the number of rows and blocks in the table.
140 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The optimizer statistics are automatically collected and stored if you create a database using the DBCA GUI tool. You can also collect the optimizer statistics manually by using the DBMS_STATS package. Automatic Collection of Statistics Oracle automatically collects and stores the optimizer statistics for various database objects. These statistics are stored regularly by scheduled maintenance jobs. The GATHER_STATS_JOB database job helps to store the optimizer statistics. The GATHER_STATS_JOB job is automatically created when you create a database. The GATHER_STATS_JOB database job is managed by the Scheduler, which runs the job when the maintenance window is opened. The optimizer statistics collected by the GATHER_STATS_JOB job are of two types, missing statistics and stale statistics. Missing statistics means that the data dictionary does not contain optimizer statistics about tables, columns, or indexes in a database. Stale statistics means that the data dictionary does not contain up-to-date optimizer statistics about tables, columns, or indexes. When a database is created or upgraded, the automatic collection of optimizer statistics is enabled by default. Execute the following statement to verify whether or not automatic collection of the optimizer statistics is enabled: SQL> SELECT * FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME=‘GATHER_STATS_JOBS’; Manual Collection of Statistics You can manually collect optimizer statistics in all schemas, including the system schemas. You can use the DBMS_STATS PL/SQL package to collect optimizer statistics on tables and indexes, and columns and partitions of a table. Table 8-1 lists the procedures in the DBMS_STATS package. Procedure GATHER_INDEX_STATS GATHER_TABLE_STATS GATHER_SCHEMA_STATS GATHER_DICTIONARY_STATS GATHER_DATABASE_STATS
Description Collects statistics on indexes Collects statistics on a table, column, or index Collects statistics on all database objects of a specified schema. Collects statistics on all dictionary objects Collects statistics on all database objects
Table 8-1: Statistics Collection Procedures in DBMS_STATS package Viewing Performance Metrics A performance metric is a collection of database performance statistics that are collected and stored in Automatic Workload Repository (AWR). The performance metrics, such as throughput, response time, and Input/Output (I/O) time, help you to analyze the performance of a database. Note: AWR is a collection of tables that stores the performance metrics of a database.
141 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
To view the performance metrics, click the All Metrics link at the bottom of the Database Control Home page of the Enterprise Manager. The All Metrics page is displayed. Figure 8-5 shows the All Metrics page.
Figure 8-5: The All Metrics Page You can click the link of the desired metric to view the detailed information about the selected metric.
142 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Proactive Maintenance Scope •
Understand the function and process of Automatic Database Diagnostic Monitoring (ADDM).
•
Identify the uses and describe how to manage Automatic Workload Repository (AWR).
•
Describe how to manage baseline metrics and alerts thresholds.
Focused Explanation Introducing Proactive Maintenance Proactive maintenance is a technique that helps you to identify and rectify database performance issues before, during, or immediately after these performance issues occur. Oracle 10g introduces two new features, Automatic Database Diagnostic Monitoring (ADDM) and Automatic Workload Repository (AWR), which allow you to proactively identify and rectify the database performance issues. Introducing ADDM ADDM is a self-diagnostic engine that automatically monitors and analyzes the database performance statistics at regular intervals. ADDM performs the following functions: •
Provides the results of the analysis of database performance statistics
•
Offers information about the effects of the database performance issues on the performance of a database
•
Includes recommendations to rectify the database performance issues
•
Offers information about the benefit of rectifying the database performance issues
ADDM contains a set of diagnostic advisors that help you to identify and rectify database performance issues. The following are some of the diagnostic advisors provided by ADDM: •
SQL Tuning Advisor – Identifies the SQL statements that have poor execution plans. SQL Tuning Advisor also helps to formulate efficient execution plans for executing the SQL statements.
•
SQL Access Advisor – Helps to reduce the CPU processing time, I/O time, and response time for a specified SQL statement.
•
Memory Advisor – Provides recommendations to tune the memory structures of Oracle, such as the System Global Area (SGA).
•
Segment Advisor – Identifies the tablespace segments that can be shrunk, to optimize the use of space in an Oracle database.
143 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Undo Management Advisor – Identifies the database performance issues related to undo segments in a database. Undo Management Advisor also provides proactive recommendations to rectify these database performance issues.
Working with ADDM You can use the data dictionary views of ADDM to identify, analyze, and view recommendations to rectify the database performance issues. Table 8-2 lists some of the data dictionary views of ADDM.
Data Dictionary View DBA_ADVISOR_FINDINGS DBA_ADVISOR_OBJECTS DBA_ADVISOR_RECOMMENDATIONS
DBA_ADVISOR_RATIONALE
Description Identifies the database tasks that affect the performance of a database. Provides the description of database tasks identified by the DBA_ADVISOR_FINDINGS view. Provides recommendations to rectify the performance of the database tasks identified by the DBA_ADVISOR_FINDINGS view. Provides information about the reason of the performance issue related to the database tasks identified by the DBA_ADVISOR_FINDINGS view.
Table 8-2: Data Dictionary Views of ADDM For example, to identify and provide recommendations about the database task that consumes maximum DB time, complete the following steps: 1. Identify the task that is consuming the maximum DB time using the DBA_ADVISOR_FINDINGS data dictionary view, as shown in the following statement: SQL> SELECT task_id, type, message 2 FROM DBA_ADVISOR_FINDINGS 3 WHERE impact=(SELECT MAX (impact) FROM DBA_ADVISOR_FINDINGS); Output similar to the following will be displayed: TASK_ID ---------
TYPE -----------
164 PROBLEM time were found.
MESSAGE --------------------------------------------------------------------------------------------SQL
statements
consuming
significant
database
This statement identifies a database task, with TASK_ID 164, which is consuming maximum DB time.
144 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
2. Retrieve the description of the task that is consuming maximum DB time, using the DBA_ADVISOR_OBJECTS data dictionary view, as shown in the following statement:
SQL> SELECT attr4 2 FROM DBA_ADVISOR_OBJECTS 3 WHERE task_id=164; Output similar to the following will be displayed:
ATTR4 ---------------------------------------------------------------------UPDATE WHERE
customer
cust_id
= : B1
DELETE AND
FROM
SET
sales
credit_limit = credit_limit * 1.15
WHERE
time_id
BETWEEN
‘01_JAN-00’
’01-JAN-01’; UPDATE WHERE
sales_history
CHANNEL_ID
SET
quantity_sold = quantity_sold+10
:= B1
SELECT
COUNT(*)
FROM
sales_history;
SELECT
DISTINCT channel_id
FROM
sales_history;
3. Retrieve the recommendation to rectify the performance issue of the task, as shown in the following statement:
SQL> SELECT TRIM(attr1) ATTR1, TRIM(attr2) ATTR2, TRIM(attr3) ATTR3 2 FROM DBA_ADVISOR_ACTIONS 3 WHERE task_id=164;
145 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Output similar to the following will be displayed:
ATTR1
ATTR2
------------
ATTR3
-----------
------------
log_buffer
262144
15728640
db_cache_size
25165824
50331648
undo_retention
900
363
In this output, ADDM recommends that the values of the LOG_BUFFER, DB_CACHE_SIZE, and UNDO_RETENTION parameters be changed to 15728640 bytes, 50331648 bytes, and 363 seconds, respectively. 4. Retrieve information about the reason for the high DB time consumption, as shown in the following statement: SQL> SELECT
message FROM DBA_ADVISOR_RATIONALE WHERE task_id=164;
Output similar to the following will be displayed: MESSAGE -------------------------------------------------------------------------Buffer cache writes due to small log files were consuming significant database time. The buffer cache was undersized causing significant read I/O. The value of “undo retention” was 900 seconds and the longest running query lasted only 330 seconds. This extra retention caused unnecessary I/O. Introducing AWR AWR stores run-time statistics collected by Memory Monitor (MMON) and Memory Monitor Light (MMNL) in the form of snapshots. MMON and MMNL are two new background processes in Oracle 10g that collect performance statistics directly from the SGA. AWR stores the performance statistics for all SQL statements executed in the database at regular intervals. Note: A snapshot provides a summary of database performance statistics. You can use AWR to gather the following types of database performance statistics: •
Performance problems related to wait events.
•
DB time associated with a process. AWR gathers the statistics on DB time by using the V$SESS_TIME_MODEL and V$SYS_TIME_MODEL views.
146 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Active Session History (ASH) statistics. AWR uses the V$ACTIVE_SESSION_HISTORY view to gather the ASH statistics.
•
System and session statistics. AWR uses the V$SYSSTAT and V$SESSTAT views to gather system and session statistics.
•
Object usage statistics.
•
Resource-intensive SQL statements.
Managing AWR You must activate the AWR feature for rectifying the database performance issues. To activate the AWR feature, you should set the STATISTICS_LEVEL initialization parameter of the PFILE/SPFILE file to the appropriate value, such as BASIC, TYPICAL, or ALL. These values are also called statistics collection levels. AWR provides recommendations to rectify the database performance issues based on these statistics collection levels. Table 8-3 lists the statistics collection levels:
Statistics Collection Level BASIC TYPICAL ALL
Description Deactivates the AWR feature Represents the default statistics collection level of AWR Collects all statistics and provides the efficient execution plans Table 8-3: Statistics Collection Levels
The snapshots are stored in the AWR for a default period of seven days. You can use the Enterprise Manager to modify the retention period of snapshots in the AWR. To modify the period for storing the snapshots, complete the following steps: 1. Open the Administration page of the Enterprise Manager. 2. Click the Automatic Workload Repository link on Workload pane to display the Automatic Workload Repository page.
Figure 8-6 shows the Automatic Workload Repository page.
147 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 8-6: The Automatic Workload Repository Page 3. Click the Edit button on the General pane to display the Edit Settings page.
Figure 8-7 shows the Edit Settings page.
148 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 8-7: The Edit Settings Page The Edit Settings page contains the following options: •
Snapshot Retention – Modifies the period for which the snapshots are stored in the AWR.
•
Snapshot Collection – Modifies the interval at which snapshots are taken.
4. Modify the options on the Edit Settings page, and click OK to apply the settings to the AWR. Managing Baseline Metrics and Alert Thresholds A baseline metric is a set of database performance statistics that define the optimal values of various alert thresholds, such as CPU utilization, memory utilization, and response time. Baseline metrics are stored in the AWR. You can use the baseline metrics to generate alerts when a database exceeds the specified alert thresholds. Alert thresholds are of two types, warning and critical. Warning thresholds generate alerts when a database approaches a specified percentage of the specified alert threshold. Critical thresholds generate alerts when a database exceeds the specified alert threshold. The Enterprise Manager helps you create baseline metrics. To create a baseline metric, complete the following steps: 1. Open the Database Control Home page of the Enterprise Manager. Click the Manage Metrics link on the Related Links pane to display the Manage Metrics page.
149 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
2. Click the Metric Baselines tab to display the Metric Baselines tab page. Figure 8-8 shows the Metric Baselines tab page.
Figure 8-8: The Metric Baselines Tab Page 3. Click the Create button to display the Create Metric Baseline page.
Figure 8-9 shows the Create Metric Baseline page.
150 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 8-9: The Create Metric Baseline Page 4. Type the name of the metric baseline in the Name text box. Specify the date and time to activate the metric baseline. Type the values for the warning and critical thresholds in the Warning Percentage and Critical Percentage text boxes, respectively. 5. Click OK to create the baseline metric. You can also use the Enterprise Manager to set the warning and critical thresholds. To set the thresholds, complete the following steps: 1. Open the Manage Metrics page of the Enterprise Manager. 2. Click the Edit Thresholds button to display the Edit Thresholds page.
Figure 8-10 shows the Edit Thresholds page.
151 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 8-10: The Edit Thresholds Page 3. Set the values of the warning and critical thresholds for the different metrics on the Edit Thresholds page. Click OK to apply the settings.
152 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Performance Monitoring and Proactive Maintenance: Oracle 10g Administration I Describe how to troubleshoot invalid and unusable objects. Describe how to collect optimizer statistics in Oracle 10g. Describe how to view performance metrics in Oracle 10g. Describe how to collect optimization statistics. Describe how to view performance metrics. Describes how to work with ADDM. Describe how to manage AWR. Describe how to manage baseline metrics and alert thresholds.
153 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Maintaining Consistency and Concurrency in Databases: Oracle 10g Administration I
154 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Performing Undo Management Scope •
Describe undo management in Oracle 10g.
•
Identify how to configure, monitor, and manage the undo tablespace using SQL statements.
•
Describe the undo tablespace parameters, such as UNDO_MANAGEMENT, UNDO_TABLESPACE, and UNDO_RETENTION.
Focused Explanation Describing Undo Management Whenever a modification is made to the database, either by a user or a Data Manipulation Language (DML) statement, the Oracle database maintains the old data. This information is referred to as undo data and it is used to roll back the changes made to the database by transactions performed by the users. This information is stored in the undo tablespace. Configuring and monitoring the undo tablespace is known as undo management. Some of the benefits of undo management include: •
Help in the roll back or undo of the changes made to a database
•
Support for read-consistent queries
•
Support for flashback queries
Introducing Undo Segments Undo segments are memory segments that are made up of extents. Each extent is a collection of data blocks. The data contained in the undo segments is similar to data stored in a table. An undo segment contains pre-updated image values, the transaction ID, the datafile number, the block address, and the status of a database transaction. Undo segments are also called rollback segments. Undo segments are stored in the undo tablespace. A database can contain more than one undo tablespace, but only one undo tablespace can be active at a time. Undo segments contain undo data and information about the tables involved in a database transaction. When a new transaction starts, it is assigned to an undo segment in the undo tablespace. The assigned undo segment stores the changes made by the transaction to a table. You can retrieve the name of the currently-active undo segment by querying the V$ROLLNAME view. The following statement shows how to retrieve the name of the currently-active undo segment: SQL> SELECT * FROM V$ROLLNAME; Note: You can view both the active and the inactive undo segments of the SYSTEM and undo tablespaces by querying the DBA_ROLLBACK_SEGS view.
155 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Every undo segment in an undo tablespace is assigned a specific Undo Segment Number (USN). The USN 0 is reserved for system users, such as SYS or SYSTEM. If no undo segment is active at any particular time, the transactions are stored in the SYSTEM tablespace. An undo transaction can only be stored in one undo segment, and it cannot be moved to another undo segment. However, different undo transactions can be stored in a single undo segment. Each undo segment is made up of a minimum of two extents. However, the limit on the maximum number of extents in an undo segment is not defined. For example, in an undo segment with a block size of 8 KB, the maximum number of extents available is 32,765. If an extent in the undo segment is filled, the next available extent is used to store the current transaction. If the current transaction uses all the extents in an undo segment, a new extent is allocated to the undo segment. All the undo segments are owned by SYS, regardless of the users that are performing the transactions. Using Undo Data You can use the undo data for: •
transaction rollbacks
•
read consistency of queries
•
database recovery operation
•
flashback queries
When you roll back a transaction, the undo information about the transaction is retrieved from the undo tablespace and changes made from the beginning of the transaction are undone. Undoing the changes made by a transaction in the database is referred to as rolling back of a transaction. The information required to roll back the changes is known as rollback information. Undo data also provides read consistency to the users who are querying the same table or rows involved in a DML transaction performed by another user. If one user starts changing a table and another user issues a query on the same table, then the user issuing the query cannot view the changes until the query changing the table finishes executing. The changes in the table are displayed as soon as the user issues another query on the same table. When a database user issues a SELECT statement before the DML statement is committed, undo segments restructure the data blocks to provide the previous values of the rows in a table. Until you roll back or commit a transaction, the queries in the transaction can only display those changes in the tables that were committed before that transaction began.
156 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following statements are only permitted in a read-consistent query: SELECT statement without the FOR UPDATE clause LOCK TABLE SET ROLE ALTER SESSION ALTER SYSTEM Undo data is used to recover a database in case of system failure. The use of active redo log files retrieves both committed and uncommitted transactions from the point of system failure, and recovers the database. The uncommitted transactions are rolled back using the undo data in the undo tablespace. Undo data also supports flashback queries to retrieve earlier versions of a table from the undo tablespace. Managing the Undo Tablespace You can manage the undo tablespace by configuring and monitoring the undo tablespace. You can configure the undo tablespace using initialization parameters. You can monitor the undo tablespace by using Undo Advisor in Enterprise Manager Database Control. Configuring the Undo Tablespace You can configure the undo tablespace either manually or automatically. You can use manual undo management for providing backward compatibility with Oracle 8i or earlier versions of Oracle. You can use the undo parameters, such as UNDO_MANAGEMENT, UNDO_TABLESPACE, and UNDO_RETENTION initialization parameters for automatic undo management. The UNDO_MANAGEMENT Initialization Parameter The UNDO_MANAGEMENT initialization parameter specifies how the undo data is managed in the database, either manually using rollback segments or automatically using a tablespace. This initialization parameter accepts one of two values, MANUAL or AUTO. The statement to change the undo management mode is: SQL> ALTER SYSTEM 2 SET UNDO_MANAGEMENT=MANUAL SCOPE=SPFILE; Note: You need to restart a database instance to ensure that the changes made to the undo management mode are applied effectively to the database. The UNDO_TABLESPACE Initialization Parameter The UNDO_TABLESPACE initialization parameter specifies the name of the undo tablespace to store the undo transactions. Only one undo tablespace can be active at a given time, unless the value of the UNDO_TABLESPACE initialization parameter is changed while the first tablespace contains active
157 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
transactions. For example, if an undo tablespace is used to store undo data and the UNDO_TABLESPACE initialization parameter value is changed to provide a new undo tablespace, the old undo tablespace will remain active until the last transaction using the old undo tablespace is committed or rolled back. All the new undo transactions will use the new undo tablespace specified in the UNDO_TABLESPACE initialization parameter. If the UNDO_TABLESPACE initialization parameter is not defined and if only one undo tablespace exists in the database, the first undo tablespace that is encountered by the Oracle instance at startup is assigned to the UNDO_TABLESPACE initialization parameter. You can use the SQL*Plus SHOW PARAMETER command to identify the name of the current undo tablespace. The following SQL statement shows the name of the current undo tablespace: SQL> SHOW PARAMETER UNDO_TABLESPACE; If the undo tablespace is not explicitly created using the CREATE DATABASE statement, Oracle automatically creates an undo tablespace with the name SYS_UNDOTABS. You can also change the undo tablespace using the ALTER SYSTEM statement. For example, the following SQL statement shows how to change the undo tablespace from the current undo tablespace to the UNDOTABSTWO tablespace: SQL> ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTABSTWO; The UNDO_RETENTION Initialization Parameter The UNDO_RETENTION initialization parameter specifies the time, in seconds, for which the undo information is retained in the undo tablespace, until that information is overwritten. You cannot guarantee the time specified in the UNDO_RETENTION parameter. This is because if the time specified in the UNDO_RETENTION parameter is not completed and a transaction needs undo space, the already committed undo information is overwritten. You can tune the automatic undo retention by setting the value of the UNDO_RETENTION initialization parameter to zero. This initialization parameter is adjusted regularly to accommodate the longest-running query. The longest-running query is the set of SQL statements that need maximum system resources. If the undo tablespace cannot accommodate the longest-running query, automatic undo retention retains the maximum amount of undo information without extending the undo tablespace. Automatic undo retention can retain the undo information for at least 900 seconds. The following are the three types of undo information: •
Uncommitted undo information: The undo information that supports an active transaction. This information is never overwritten and is required to roll back a transaction in case of a transaction failure.
•
Committed undo information: The undo information that is no longer required for an active transaction, but is required by the UNDO_RETENTION initialization parameter. You can overwrite this undo information, if a current transaction requires undo tablespace.
•
Expired undo information: The undo information that is no longer required for an active transaction and is overwritten when space is required by a current transaction.
158 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Monitoring the Undo Tablespace You can monitor an undo tablespace to determine the amount of space required by an undo tablespace. Undo tablespaces are monitored in the same way as other tablespaces in a database. If the warning and critical thresholds of undo tablespace are not defined, the default database threshold values are used. You can also define warning and critical threshold values for an undo tablespace using Enterprise Manager Database Control. When the datafiles in the undo tablespace do not have the AUTOEXTEND attribute set, transactions can fail because the undo space required by the transactions may be higher than the actual space in the undo tablespace. When an undo tablespace uses the default threshold values of the database, the database issues a warning alert at 85 percent and a critical alert at 97 percent. Ideally, you should resize the undo tablespace when a warning alert is generated and reallocate the space before the critical threshold is reached. Initially, you can use the AUTOEXTEND attribute with the datafiles of the undo tablespace, but if the undo tablespace is sized correctly, the AUTOEXTEND attribute can be turned off. This prevents a user from using a large amount of disk space in the undo tablespace, by neglecting to commit transactions frequently. Using Undo Advisor to Size the Undo Tablespace The Undo Advisor helps you to determine the recommended size of the undo tablespace required for adequate undo retention. By default, the Undo Advisor has the undo retention period of 70 minutes and an undo tablespace size of 80 MB. If you expect the undo information to increase or do not want to retain the undo information for more than 70 minutes, you can decrease the size of the undo tablespace. You can also increase the size of undo tablespace by providing a new value for undo retention. To manage the size of the undo tablespace using Undo Advisor, complete the following steps: 1. Open the Database Home page on Enterprise Manager Database Control. 2. Click the Advisor Central link on the Database Home page. The Advisor Central page is displayed. 3. Click the Undo Management link on the Advisor Central page. The Undo Management page is displayed. 4. Click the Undo Advisor button on the Undo Management page. The Undo Advisor page is displayed. You can increase the size by entering a new value for undo retention in the New Undo Retention text box on the Undo Advisor page or by clicking the new undo retention limit on the Required Tablespace Size by Undo Retention Length graph on the Undo Advisor page. Using the V$UNDOSTAT View to Size the Undo Tablespace Enterprise Manager Database Control uses the V$UNDOSTAT view to determine the undo tablespace size and provide recommendations for increasing or decreasing the size.
159 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
You can use the following formula to calculate the optimum size of the undo tablespace: UNDO_TABLESPACE_SIZE = UR * UPS In this formula, UR is the undo retention and UPS is the maximum undo blocks used per second in the V$UNDOSTAT view. For example, if the database has a block size of 8 KB, you can calculate the optimum size of the undo tablespace in the following way: UNDO_TABLESPACE_SIZE = 43200 * 626 * 8192 = 221537894400 BYTES = 206GB In this calculation, 43200 is the value of the UNDO_RETENTION parameter, 626 is the number of undo blocks, and the converted value of database block size of 8KB is 8*1024=8192 bytes.
160 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Monitoring and Resolving Lock Conflicts Scope •
Define locks and transactions.
•
Describe the various lock modes supported by the Oracle database.
•
Identify the causes of lock conflicts and understand how to resolve deadlocks.
Focused Explanation Introducing Locks and Transactions Locks prevent a second user from changing the same data that another user is already in the process of changing. Locks also help in maintaining read consistency. A lock provides the user with exclusive control over the data until the user commits or rolls back the transaction that is changing the data. The user executing the DML statement must lock the rows before changing the rows in a table. In Oracle 10g, a transaction can lock a single row, multiple rows, or an entire table. You can lock the rows both manually and automatically. The rows can be locked at the lowest possible access level to ensure data integrity. You can also configure locks to minimize the conflict with other transactions that may need to access other rows in the table. For example, two transactions might use two different sessions to update rows in a table, EMPLOYEE. The EMPLOYEE table has three columns, EMPLOYEE_ID, MANAGER_ID, and SALARY. While the first transaction is updating the SALARY column of the EMPLOYEE table, the second transaction cannot access the SALARY column in the EMPLOYEE table. However, the second transaction can update other rows or columns of the table which are not locked by the first transaction. Table 9-1 shows concurrent transactions on different rows of the EMPLOYEE table.
Session 1
Time
Session 2
UPDATE EMPLOYEE SET SALARY = SALARY * 1.2 WHERE EMPLOYEE_ID = 76;
11:29 P.M.
UPDATE EMPLOYEE SET MANAGER_ID = 135 WHERE EMPLOYEE_ID = 204;
COMMIT;
11:30 P.M.
COMMIT;
Table 9-1: Concurrent Transactions on Different Rows of the EMPLOYEE Table In Table 9-1, both the updates are successful because the locks are on different rows in the EMPLOYEE table and neither session is waiting for the other lock to be released.
161 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The first transaction is updating the row where the employee ID is 76, and the second transaction is updating the row where the employee ID is 204. A lock does not affect the queries executed during a transaction. If a transaction locks some rows of a table, a query uses the pre-lock image values of the data stored in the undo tablespace. When multiple users request locks on the same rows in a table, the first user to request the lock acquires the lock. The remaining users are handled using the first-in, first-out (FIFO) method. You can override these automatic locks using the LOCK statement. Using the LOCK statement with the NOWAIT keyword will attempt to immediately lock the specified table. However, if a lock already exists on the specified table, Oracle immediately returns a message indicating that the table is already locked by another user. The following example shows the use of the NOWAIT keyword in the LOCK TABLE statement: SQL> 2 3 lock
LOCK TABLE EMPLOYEE IN SHARE ROW EXCLUSIVE MODE NOWAIT table employee * ERROR at line 1: ORA-00054: resource busy and acquire with NOWAIT specified If you include the WAIT keyword with the LOCK statement, Oracle will wait for the table to become available and then lock the specified table and return control to the user. When either a COMMIT or ROLLBACK statement is issued or a transaction is ended implicitly, all locks held by the transaction are released. The COMMIT or ROLLBACK statement is issued either explicitly or implicitly by the user, when the session terminates normally or abnormally. Identifying Lock Modes You can use locks on different entities of a database, such as tables and views. Lock modes are used to define the access type and access level on the tables that are being used in the DML statements. For example, when a user configures a shared lock on a database object, the database object is locked for editing. Other users can access the table but no changes can be made to the table. Oracle 10g provides various lock modes on the database objects such as SHARE and EXCLUSIVE. The following are the types of lock modes used in a table: •
ROW SHARE – Permits access to the locked table but prevents other users from locking the entire table for exclusive access.
•
ROW EXCLUSIVE – Permits access to the locked table but also prevents locking in the ROW SHARE mode. This lock is automatically obtained using DML statements, such as UPDATE, INSERT, or DELETE.
•
SHARE – Permits simultaneous queries on a table but prevents updates to the table. This mode is required to create an index on a table and is automatically obtained when the CREATE INDEX statement is used.
162 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
SHARE ROW EXCLUSIVE – Permits other users to query a table but prevents them from locking the table in the ROW SHARE mode or updating the rows.
•
EXCLUSIVE – Permits queries on the locked tables but prevents DML statements to be performed on the locked table. This mode is required to drop a table and is automatically obtained when the DROP TABLE statement is used.
You can explicitly lock individual rows in a table using the SELECT...FOR UPDATE statement. The following SQL statement shows the rows in the EMPLOYEE table locked using the SELECT...FOR UPDATE statement: SQL> SELECT * FROM EMPLOYEE 2 WHERE MANAGER_ID = 200 3 FOR UPDATE; This SELECT statement retrieves the rows that satisfy the condition specified in the WHERE clause, locks the selected rows, and prevents other transactions from locking or updating these rows until a COMMIT or ROLLBACK statement is issued. Identifying and Resolving Lock Conflicts Sometimes you cannot avoid the occurrence of locks in a database, and these locks are placed in a queue and resolved automatically. However, in some situations, you need to manually resolve lock conflicts. For example, a user might issue a DML statement on a table at 5:20 P.M. and forget to issue a COMMIT statement before leaving for the day. This DML statement would continue to hold locks on the table. Other lock conflicts can be caused due to long-running transactions. For example, if a transaction issues thousands of DML statements overnight to update tables in a data warehouse, the transactions might not complete before the beginning of the next business day. The uncommitted transactions would hold locks on these tables and users would not be able to update the tables until the lock conflicts were resolved. A user can resolve a lock conflict by using the COMMIT or ROLLBACK statement on the current transaction. You can identify locks in Oracle 10g using Enterprise Manager Database Control. In the Database Locks page of Enterprise Manager Database Control, you can view the locks on the database tables. Managing Deadlocks A deadlock is a special type of lock conflict in which users wait for resources locked by each other. As a result, the transactions will not be complete unless you resolve the deadlock by first detecting the deadlock and then rolling back one of the statements waiting on the resource.
163 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Table 9-2 shows two sessions that attempt to update a row locked by another session.
Session 1
Time
Session 2
11:29 P.M.
UPDATE EMPLOYEE SET
UPDATE EMPLOYEE SET MANAGER_ID = 135 WHERE EMPLOYEE_ID = 204;
SALARY = SALARY * 1.2 WHERE EMPLOYEE_ID = 76; UPDATE EMPLOYEE SET SALARY = SALARY * 1.2 WHERE EMPLOYEE_ID = 204;
11:44 P.M.
ORA-00060: DEADLOCK DETECTED WHILE WAITING FOR RESOURCE
11:45 P.M.
UPDATE EMPLOYEE SET MANAGER_ID = 135 WHERE EMPLOYEE_ID = 76; CONTROL RETURNS TO USER
Table 9-2: Updating a Row Locked by a Session After issuing the error message at 11:45 P.M., the second update for Session 1 does not succeed because the first UPDATE statement in Session 2 has a lock on the row where the employee ID is 204. The second update statement for Session 2 will be completed because the lock on the row, where the employee ID is 76, has been released by the user of Session 1 after the completion of the first update statement of Session 1. The user of Session 2 can perform another DML statement or issue a COMMIT or ROLLBACK statement, but the user of Session 1 needs to re-issue the second UPDATE statement to perform the required task.
164 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Maintaining Consistency and Concurrency in Database: Oracle 10g Administration I Describe undo management in Oracle 10g. Identify how to configure, monitor, and manage the undo tablespace using SQL statements. Describe the undo tablespace parameters, such as UNDO_MANAGEMENT, UNDO_TABLESPACE, and UNDO_RETENTION. Describe locks and transactions. Describe the various lock modes supported by the Oracle database. Describe detecting and resolving deadlocks.
165 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Performing Database Backup and Recovery: Oracle Database 10g Administration I
166 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Describing the Basics of Database Backup, Restore, and Recovery Scope •
Describe the types of database failures.
•
Define checkpoints, redo log files, and archived log files.
Focused Explanation Types of Database Failures Database failures can occur due to hardware and software problems or errors made by the database users. The following are the six types of failures that can occur in a database: •
Statement failures
•
Process failures
•
Network failures
•
User error failures
•
Instance failures
•
Media failures
Statement Failures Statement failures occur when a database operation, such as CREATE, UPDATE, or INSERT statement, fails to work. The following are the reasons for statement failures: •
when you attempt to access a table without having permissions to access the table
•
when the memory allocated to a tablespace becomes full
•
when a database application contains a logical error
Statement failures can be avoided by: •
allocating more space to tablespaces
•
providing appropriate privileges to database users
•
correcting logical errors in the database applications with the help of database application developers
167 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Process Failures A process failure is defined as a failure in a user, server, or background process of a database instance. Process failures can occur because of the following reasons: •
when a database user closes the SQL*Plus window without logging out of SQL*Plus
•
when the application program is closed due to an exception
•
when the workstation is rebooted before a database application is closed
•
when a user process times out
To recover from this failure, the Process Monitor (PMON) background process is used. This process checks for an aborted user process and resolves the failure by rolling back the current transaction. The PMON process also helps release the locks on those rows and columns that were used by the aborted user process. Network Failures Network failures can take place when hardware failures occur or a listener process on an Oracle server fails. To avoid the network failures, you can provide redundant network paths from client to the database server. You can also use multiple listener connections on the database server to overcome the network failures. User Error Failures User error failures occur when users make errors, such as deleting or modifying data in tables. You can use the ROLLBACK statement to rectify user error failures if you have not committed the records on which the user error failure occurred. If you have committed a record, you can rectify user error failures by using Flashback Query or LogMiner. Flashback Query uses an undo tablespace that retains the changes in the database for a specific time period. LogMiner helps to view the changed records in both online and archived redo log files by using PL/SQL procedures and functions. Instance Failures Instance failure occurs when a database instance shuts down due to power failure, server hardware failure, or Oracle background process failure. After the database instance restarts, Oracle automatically recovers from the instance failure. Media Failures Media failures may occur because of the following reasons: •
a database file is deleted by mistake
•
a disk drive fails
•
a disk controller fails
168 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Media failures damage datafiles, control files, and redo log files. You can recover from media failures using database backups and archived redo logs. Checkpoints, Redo Log Files, and Archived Log Files Checkpoints, redo log files, and archived log files are used to recover data or minimize the loss of data due to database failures. A checkpoint records the last System Change Number (SCN) to update the control files and datafiles in a database when you make changes in the database. A checkpoint automatically occurs if a database failure occurs when recording changes in the redo log files of a database. If there is a failure, the redo records with the changes at an SCN higher than the checkpoint are recovered. Note: SCN is a unique number assigned to a database transaction. A redo log file contains redo records, which are made up of change vectors. A change vector stores changes made to a single data block in a database. When you use redo log files to recover a database, Oracle reads the change vectors and applies the changes to the relevant data blocks. An archived log file is a copy of a redo log file and is used to recover from media failures.
169 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Performing and Managing Database Backups Scope •
Identify the types of flash recovery area files.
•
Define the types of database backups. Describe how to back up control files.
•
Understand how to create consistent, inconsistent, and incrementally updated backups.
•
Know the steps to manage database backups.
Focused Explanation The Flash Recovery Area The flash recovery area is a storage area used for the recovery of a database. The flash recovery area can be a single directory, a file system, or an Automatic Storage Management (ASM) disk group. The flash recovery area contains the following types of files: •
control files
•
archived log files
•
Recovery Manager (RMAN) backup sets
•
flashback logs
•
control file and server parameter file (SPFILE) autobackups
•
datafile copies
You can create the flash recovery area using SQL statements or using Enterprise Manager Database Control. Creating the Flash Recovery Area using SQL Statements You can create the flash recovery area by configuring two initialization parameters, DB_RECOVERY_FILE_DEST_SIZE and DB_RECOVERY_FILE_DEST using SQL statements. The DB_RECOVERY_FILE_DEST_SIZE parameter specifies the size of the flash recovery area. The DB_RECOVERY_FILE_DEST initialization parameter specifies the physical location of all the flash recovery files. You need to configure the DB_RECOVERY_FILE_DEST_SIZE initialization parameter before configuring the DB_RECOVERY_FILE_DEST initialization parameter. To configure the DB_RECOVERY_FILE_DEST_SIZE initialization parameter and specify the size of the flash recovery area as 8 GB, type the following statement at the SQL prompt: SQL> ALTER SYSTEM 2 SET DB_RECOVERY_FILE_DEST_SIZE=8G SCOPE=BOTH;
170 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
To configure the DB_RECOVERY_FILE_DEST initialization parameter and specify that the flash recovery files are stored in the ORADIR directory, type the following statement at the SQL prompt: SQL> ALTER SYSTEM 2 SET DB_RECOVERY_FILE_DEST = ‘\ORADIR’ SCOPE=BOTH; Creating the Flash Recovery Area Using Enterprise Manager Database Control You can also create the flash recovery area using Enterprise Manager Database Control. To create the flash recovery area using Enterprise Manager Database Control, complete the following steps: 1. Open the Database Home page of Enterprise Manager Database Control. 2. Click the Maintenance tab on the Database Home page. The Maintenance tab page is displayed. 3. Click the Configure Recovery Settings link. The Configure Recovery Settings page is displayed. 4. Scroll down to display the Flash Recovery Area pane on the Configure Recovery Settings page. Figure 10-1 shows the Flash Recovery Area pane.
Figure 10-1: The Flash Recovery Area Pane The following text boxes are displayed in the Flash Recovery Area pane: •
Flash Recovery Area Location – Specifies the physical location where all the flash recovery files are stored.
•
Flash Recovery Area Size – Specifies the size of the flash recovery area.
171 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
5. Type the location at which you want to store flash recovery area files, in the Flash Recovery Area Location text box. 6. Type the size of the flash recovery area in the Flash Recovery Area Size text box. 7. Click the Apply button to apply the changes. Types of Database Backups The following are the types of database backups: •
Whole backup – Creates a backup of all the datafiles and at least one control file. In whole backups, online redo log files are not backed up.
•
Partial backup – Creates a backup of one or more tablespaces. The following are the types of partial backups: o
Tablespace backup – Creates backups of the tablespace containing datafiles. You can perform tablespace backups of a database when the database is in the ARCHIVELOG mode. If you are creating a backup of the database that is running in the NOARCHIVELOG mode, the tablespace that you want to back up should be read-only.
o
Datafile backup – Performs backups of a single datafile. You can perform datafile backup of a database when it is in the ARCHIVELOG mode. You can perform datafile backup of a database in the NOARCHIVLOG mode if the datafile you want to back up is read-only or is the only file in a tablespace.
o
Control File backup – Performs a backup of a control file of a database. You can create the backup of a control file using the ALTER DATABASE BACKUP CONTROLFILE statement. You can also use the CONFIGURE CONTROLFILE AUTOBACKUP RMAN command to create a backup of a control file.
o
Archived Redo Log backup – Performs recovery of an inconsistent backup. You can create a backup of archived redo log files using the BACKUP ARCHIVELOG RMAN command.
•
Full backup – Creates a backup of all the data blocks in every datafile in a database.
•
Incremental backup – Creates a copy of the data in a database that has changed since the previous backup. There are five levels of incremental backups supported by Oracle 10g, starting from 0 to 4. The level 0 backup, referred to as a baseline backup, contains the backup of all data blocks in the datafiles that are backed up. Level 1 backs up files that changed since the last level 0 backup, level 2 backs up files that changed since the last level 1 backup, and so on. You should create this type of backup, when you want to back up only the changes recently made to a database.
172 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
•
Consistent backup – Creates a backup when a database is closed and is not available to a user. A consistent backup is also called an offline backup. When consistent backups are performed, the SCN in a control file matches with the SCN in the header of the corresponding datafile. If you create a consistent backup of a database operating in the NOARCHIVELOG mode, you should recover the database for consistency because the database in the NOARCHIVELOG mode does not archive redo log files. You should create this type of backup, when you want the database and the backup to be consistent.
•
Inconsistent backup – Creates a backup when a database is open. When inconsistent backups are performed, the SCN in a control file does not match with the SCN in the header of the corresponding datafile. If a database runs 24 hours a day and seven days a week, you should perform inconsistent database backups. The inconsistent backup is also called an online backup.
Backing up Control Files You can back up control files to prevent the loss of all control files of a database. The USER_DUMP_DEST initialization parameter is used to specify the directory in which control files are backed up. The format of the names of the backup control files is sid_ora_pid.trc, where sid specifies the session ID, pid specifies the process ID of the user creating the backup. The file extension .trc represents that the file is an editable text file. A control file is backed up to trace when the structure of the database changes, such as adding or dropping a tablespace or creating a new redo log file group. You can backup control files using SQL statements. Type the following SQL statement at the SQL prompt to create a backup control file as a trace file: SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE; You can also back up the control files by making a binary copy of the control files. Type the following statement at the SQL prompt to create a backup of the control file: SQL> ALTER DATABASE BACKUP CONTROLFILE TO ‘\U03\ORADATA\CTLFILE20040911.BKP’; Creating Consistent Database Backups To create a consistent database backup, complete the following steps: 1. Shut down the database you want to back up in the NORMAL, IMMEDIATE, or TRANSACTIONAL mode. 2. Search for *.ora in the Oracle home directory to locate the initialization parameter file. Copy the *.ora files on DISK1, to another disk, DISK2, by typing the following command at the command prompt: COPY \DISK1\ORACLE\NETWORK\ADMIN\*.ORA \DISK2\BACKUPS This command creates a backup of the initialization parameter file on DISK1, to the BACKUPS directory of DISK2.
173 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
3. Create the backups of all the datafiles and control files by typing the following commands at the command prompt: COPY $ORACLE_HOME\ORADATA\TRGT\*.DBF \DISK2\BACKUP COPY $ORACLE_HOME\ORADATA\TRGT\ARCH\* \DISK2\BACKUP\ARCH These commands create the backups of all the datafiles and control files to directories on DISK2. 4. Restart the database using the following SQL statement: SQL> STARTUP Creating Inconsistent Database Backups To create inconsistent database backups, complete the following steps: 1. Identify all the datafiles of a tablespace using the following SQL statement: SQL> SELECT TABLESPACE_NAME,FILE_NAME FROM SYS.DBA_DATA_FILES 2 WHERE TABLESPACE_NAME=‘USERS’; 2. Start the backup of the tablespace using the following SQL statement: SQL> ALTER TABLESPACE USERS BEGIN BACKUP; 3. Backup the online datafiles of the tablespace by typing the following commands at the command prompt: COPY \ORACLE\ORADATA\TRGT\USERS1.DBF \C\USERS1_ COPY \ORACLE\ORADATA\TRGT1\USERS2.DBF \C\USERS2_ These commands create backup copies of the datafiles of the tablespace USERS1 and USERS2. The commands copy the datafiles from the TRGT and TRGT1 directories of ORADATA to directories USER1 and USER2, respectively. 4. End the backup of the online tablespace using the following SQL statement: SQL> ALTER TABLESPACE USERS END BACKUP; 5. Archive the unarchived redo log files using the following SQL statement: SQL> ALTER SYSTEM ARCHIVE LOG CURRENT; Creating Incremental Backups The backup process in Oracle 10g uses RMAN to create incremental backups. The following RMAN command is used to create the baseline level 0 backup, which backs up an entire database: RMAN> BACKUP INCREMENTAL LEVEL 0 2 AS COMPRESSED BACKUPSET DATABASE;
174 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
This command backs up the database using compression to save disk space. The following RMAN command is used to create a level 1 backup: RMAN> BACKUP INCREMENTAL LEVEL 1 2 AS COMPRESSED BACKUPSET DATABASE; Creating Incrementally-Updated Backups You can also create incrementally-updated backups, which use incremental backups and back up the entire image copy by updating the changed blocks in the existing image copy. Execute the following RMAN script at the RMAN prompt to create an incrementally-updated backup: RUN {
RECOVER COPY OF DATABASE WITH TAG ‘INC_UPD_IMG’; BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG ‘INC_UPD_IMG’ DATABASE; } Managing Database Backups You can manage database backups using Enterprise Manager Database Control. You can manage the backups by maintaining the catalog, monitoring the flash recovery area, and automating backups. Maintaining the Catalog The metadata of RMAN is stored in a repository, which is also called the catalog. You can maintain the catalog using Enterprise Manager Database Control. To maintain the catalog using Enterprise Manager Database Control, complete the following steps: 1. Open the Maintenance tab page of Enterprise Manager Database Control. 2. Click the Manage Current Backups link on the Maintenance tab page. The Manage Current Backups page is displayed.
175 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 10-2 shows the Manage Current Backups page.
Figure 10-2: The Manage Current Backups Page The four buttons at the top of the Manage Current Backups page perform the following functions: o
Catalog Additional Files – Adds image copy backups, which are made outside RMAN, to the RMAN catalog.
o
Crosscheck All – Checks all backup files listed in the catalog and all the files on disk to ensure their availability.
o
Delete All Obsolete – Deletes all backup files that are not needed in the existing retention policy.
o
Delete All Expired – Deletes all the backup files that are not found in the catalog when a crosscheck is performed.
Monitoring the Flash Recovery Area You should ensure that enough space is available on the disk to store the flash recovery area files. To monitor the information about the flash recovery area, complete the following steps: 1. Open the Maintenance tab page of Enterprise Manager Database Control.
176 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
2. Click the Configure Recovery Settings link on the Maintenance tab page. The Configure Recovery Settings page is displayed. 3. Scroll down to display the Flash Recovery Area pane on the Configure Recovery Settings page. 4. Select the Delete All Obsolete option to free the disk space in the flash recovery area. You can query the V$RECOVERY_FILE_DEST data dictionary view to view more information about the flash recovery area. For example: SQL> SELECT NAME,SPACE_LIMIT, SPACE_USED, 2 SPACE_RECLAIMABLE, NUMBER_OF_FILES NUM_FILES 3 FROM V$RECOVERY_FILE_DEST; Automating Backups When you automate backups, you can specify when backups will start, repeat, and how many times backups will be repeated. To automate backups using Enterprise Manager Database Control, complete the following steps: 1. Open the Maintenance tab page of Enterprise Manager Database Control. 2. Click the Schedule Backup link on the Maintenance tab page. The Schedule Backup: Strategy page is displayed. 3. Select the Customized option from the Backup Strategy drop-down list box on the Schedule Backup: Strategy page. 4. Select the All Recovery Files on Disk option. 5. Click Next to continue. The Schedule Backup: Options page is displayed. 6. Click Next to continue. The Schedule Backup: Settings page is displayed. 7. Click Next to continue. The Schedule Backup: Schedule page is displayed. This page shows the following sections: o
Job – Specifies the name and description of the backup job.
o
Schedule – Specifies the time zone.
o
Start – Specifies the time to start the backup.
o
Repeat – Specifies whether to repeat the backup.
o
Repeat Until – Specifies for how long backups will be performed, if repeated backups are created.
177 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 10-3 shows the Schedule Backup: Schedule page.
Figure 10-3: The Schedule Backup: Schedule Page 8. Type the required settings in the different sections. 9. Click Next to continue. The Schedule Backup: Review page is displayed. 10. Click Submit Job. The database backup starts immediately if you select the Immediately option in the Start section. The database backup starts at a later time if you select the Later option in the Start section.
178 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Performing Database Recovery Scope •
Describe how to recover from various types of failures such as instance failures and user process errors.
Focused Explanation Recovering from Instance Failures Oracle recovers from the instance failures during instance recovery. You can start instance recovery by issuing the STARTUP command. When an instance failure occurs, Oracle performs instance recovery in the following two phases: 1. Oracle restores datafiles using the online redo log files. 2. Oracle rolls back all the uncommitted transactions using the undo tablespace. Tuning Instance Recovery You can minimize the impact of an instance failure by tuning the instance recovery operation in a database. This operation ensures that the distance between the checkpoint position and the end of the redo log group is not more than 90% of the size of the redo log group. You can tune instance recovery by using the FAST_START_MTTR_TARGET initialization parameter. The default value of the FAST_START_MTTR_TARGET initialization parameter is 0 and the maximum value is 3600. If the value of this parameter is high, the time to recover from an instance failure will be greater. To specify the value of the FAST_START_MTTR_TARGET initialization parameter using the ALTER SYSTEM statement, type the following statement at the SQL prompt: SQL> ALTER SYSTEM SET FAST_START_MTTR_TARGET=60 SCOPE=BOTH; Recovering a Control File The loss of a control file immediately terminates a database instance, which can corrupt the datafiles of the database. Therefore, you need to recover a control file. To recover a control file, complete the following steps: 1. Start the database in the NOMOUNT mode. 2. Copy one of the correct copies of the control file to the location of the corrupted or missing control file. 3. Copy the corrupted control file to another location if it is stored on a failed disk. 4. Update the initialization parameter file to update the control file reference. 5. Start the instance with the STARTUP command.
179 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
The following example explains these steps using SQL statements: 1. Type the following SQL statement at the SQL prompt to start the database in the NOMOUNT mode: SQL> STARTUP NOMOUNT 2. Type the following statement at the SQL prompt to identify the online control files: SQL> SHOW PARAMETERS control_files 3. Use the following statement to check the copies of the control file to be copied to the location at which the corrupted control file is stored: SQL> SELECT NAME, VALUE FROM V$SPPARAMETER WHERE NAME=‘CONTROL_FILES’; The output of this SELECT statement might be: NAME ------------CONTROL_FILES CONTROL_FILES CONTROL_FILES
VALUE ----------------\U02\ORADATA\ORD\CONTROL01.CTL \U06\ORADATA\ORD\CONTROL02.CTL \U07\ORADATA\ORD\CONTROL03.CTL
4. Restart the instance and change the value of the CONTROL_FILES initialization parameter, using the following statement: SQL> ALTER SYSTEM SET CONTROL_FILES=‘\U02\ORADATA\ORD\CONTROL01.CTL’, ‘\U06\ORADATA\ORD\CONTROL02.CTL’ SCOPE=SPFILE; 5. Shut down the database instance using the following command: SQL> SHUTDOWN IMMEDIATE 6. Restart the instance using the following command: SQL> STARTUP 7. Use the following statement to confirm that the corrupted control file is not referenced when the database instance is restarted successfully: SQL> SELECT NAME, VALUE FROM V$SPPARAMETER WHERE NAME=‘CONTROL_FILES’; Recovering a Redo Log File The alert log records the loss of a member of a redo log group. To recover a redo log file, complete the following steps: 1. Identify the missing redo log file group member by querying the V$LOGFILE data dictionary view, as shown in the following SQL statement:
180 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
SQL> SELECT * FROM V$LOGFILE ORDER BY GROUP#; The output of this SELECT statement might be: GROUP# ------1 1 2 2
STATUS -------INVALID
TYPE ----ONLINE ONLINE ONLINE ONLINE
MEMBER -------\U07\ORADATA\ORD\REDO01.LOG \U08\ORADATA\ORD\REDO01.LOG \U07\ORADATA\ORD\REDO02.LOG \U08\ORADATA\ORD\REDO02.LOG
The output shows that the REDO01.LOG member of redo log group 1 is missing because its status is INVALID in the STATUS column. The STATUS column of the V$LOGFILE view can have one of the following values: o
INVALID: Specifies that the redo log file group member is corrupted or missing.
o
STALE: Depicts that the redo log file group member is new.
o
DELETED: Depicts that the redo log file group member is no longer in use.
o
: Depicts that the redo log file group member is in use and is not corrupted.
2. Archive the contents of the redo log file group, 1. Use the following SQL statement to archive the redo log file group,1: SQL> ALTER SYSTEM ARCHIVE LOG GROUP 1; 3. Create the missing redo log file group member of the redo log file group, 1, using the following SQL statement: SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1; Recovering a System-Critical Datafile A datafile in the SYSTEM or undo tablespace is called a system-critical datafile. If you lose a systemcritical datafile, when a database is open in the NOARCHIVELOG mode, you need to restore a database completely with its control files and datafiles. If you lose a system-critical datafile when a database is open in ARCHIVELOG mode, you need to shut down the database and reopen it in the MOUNT mode. To shut down the database and restart it in the MOUNT mode type the following statement at the SQL prompt: SQL> SHUTDOWN ABORT SQL> STARTUP MOUNT You can now recover a system-critical datafile in the ARCHIVELOG mode using Enterprise Manager Database Control. To recover a system-critical file using Enterprise Manager Database Control, complete the following steps:
181 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
1. Open Enterprise Manager Database Control in the Web browser. The Database: oracle page is displayed. Figure 10-4 shows the Database: oracle page.
Figure 10-4: The Database: oracle Page 2. Click the Perform Recovery button on the Database: oracle page. The Perform Recovery: Credentials page is displayed. 3. Type the Host and Database Credentials on the Perform Recovery: Credentials page. 4. Click the Continue button. The Perform Recovery: Type page is displayed. 5. Select the Datafiles option from the Objects Type drop-down list box on the Perform Recovery: Type page. 6. Click Next to continue. The Perform Recovery: Datafiles page is displayed. 7. Select the system-critical datafile you want to recover. 8. Click Next to continue. The Perform Recovery: Rename page is displayed. 9. Select the Yes option to restore the system-critical datafile to a new location. 10. Type the location to which you want to restore the datafile in the Location text box. 11. Click Next to continue. The Perform Recovery: Review page is displayed.
182 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
12. Click Submit to perform recovery of the system-critical datafile. Recovering a Non-System-Critical Datafile To recover a lost non-system-critical datafile in the NOARCHIVELOG mode, you should completely restore a database with control files and datafiles. To recover a non-system-critical datafile in the ARCHIVELOG mode using Enterprise Manager Database Control, complete the following steps: 1. Open the Maintenance tab page of Enterprise Manager Database Control. 2. Click the Perform Recovery link on the Maintenance tab page. The Perform Recovery: Type page is displayed. 3. Select the Datafiles option from the Objects Type drop-down list box on the Perform Recovery: Type page. 4. Select the Operation Type as Recover to Current Time or a Previous Point-in-Time option. 5. Click Next to continue. The Perform Recovery: Datafiles page is displayed. 6. Select the non-system-critical datafile you want to recover. 7. Click Next to continue. The Perform Recovery: Rename page is displayed. 8. Select the Yes option to restore the non-system-critical datafile to a new location. 9. Type the location to which you want to restore the non-system-critical datafile in the Location text box. 10. Click Next to continue. The Perform Recovery: Review page is displayed. 11. Click Submit to perform recovery of the non-system-critical datafile. Recovering from User Error Failures User error failures occur when users perform errors by modifying or deleting tables from a database by mistake. You can use the following utilities to recover from user errors: •
Flashback Query
•
Flashback Drop
•
Flashback Table
•
LogMiner
Flashback Query Flashback Query allows you to view the contents of a table from sometime in the past. You need to perform the following tasks before using Flashback Query:
183 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
1. Ensure that there is an undo tablespace in the database that retains the changes made for a specified period of time. 2. Use the UNDO_RETENTION initialization parameter to specify how long the undo data is retained for use by Flashback Query. For example, to retrieve the contents of the EMPLOYEE table, as the EMPLOYEE table existed 15 minutes before the current time, type the following SQL statement at the SQL prompt: SQL> SELECT EMP_ID, EMP_NAME FROM EMPLOYEE AS OF 2 TIMESTAMP(SYSTIMESTAMP–INTERVAL ‘15’ MINUTE); You can also specify the actual time on which you want to retrieve the contents of the EMPLOYEE table, using the following SQL statement: SQL> SELECT EMP_ID, EMP_NAME FROM EMPLOYEE AS OF TIMESTAMP 2 TO_TIMESTAMP(‘02-OCT-04 16:19:56.845993’,’DD-SAT-RR HH24:MI:SS.FF’)); Flashback Drop Flashback Drop allows you to restore a table that you have dropped by mistake. The Recycle Bin is a logical structure that stores dropped tables. The objects stored in the Recycle Bin are deleted in first-infirst-out manner. You can retrieve a dropped table from the Recycle Bin using the FLASHBACK TABLE TO BEFORE DROP statement. For example, to retrieve a dropped table, ORDER, type the following SQL statement at the SQL prompt: SQL> FLASHBACK TABLE ORDER TO BEFORE DROP; Flashback Table Flashback Table helps you to recover database objects from a point of failure. The undo tablespace is used by Flashback Table to recover tables. For example, if you have accidentally deleted some rows from the DEPARTMENT table, you can use Flashback Table to recover the deleted rows. To flashback a table, you must enable row movement for the table because Data Manipulation Language (DML) operations restore a table to its previous state. To enable the row movement in the DEPARTMENT table, type the following statement at the SQL prompt: SQL> ALTER TABLE DEPARTMENT ENABLE ROW MOVEMENT; You can use the FLASHBACK TABLE statement to recover the rows deleted from the DEPARTMENT table. To recover the rows deleted from the DEPARTMENT table, type the following statement at the SQL prompt: SQL> FLASHBACK TABLE DEPARTMENT TO TIMESTAMP SYSTIMESTAMP-INTERVAL ‘15’ MINUTE; This statement recovers all the rows that have been deleted from the DEPARTMENT table 15 minutes before the execution of the FLASHBACK TABLE statement.
184 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
You can also flashback a table using Enterprise Manager Database Control. To flashback a table using Enterprise Manager Database Control, complete the following steps: 1. Open the Maintenance tab page of Enterprise Manager Database Control. 2. Click the Perform Recovery link on the Maintenance tab page. The Perform Recovery: Type page is displayed. Figure 10-5 shows the Perform Recovery: Type page.
Figure 10-5: Perform Recovery: Type Page 3. Select the Tables option from the Object Type drop-down list box. 4. Click the Next button to continue. The Perform Recovery: Point-in-time page is displayed.
185 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 10-6 shows the Perform Recovery: Point-in-time page.
Figure 10-6: The Perform Recovery: Point-in-time Page 4. Select the Flashback to a timestamp option on the Perform Recovery: Point-in-time page. 5. Click the Next button to continue. The Perform Recovery: Flashback Tables page is displayed.
186 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 10-7 shows the Perform Recovery: Flashback Tables page.
Figure 10-7: The Perform Recovery: Flashback Tables Page 6. Type the name of the table you want to recover in the Tables To Flashback text box. 7. Click Next to continue. The Dependency Options page is displayed.
187 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Figure 10-8 shows the Dependency Options page.
Figure 10-8: The Dependency Options Page 8. Click Next to continue. The Perform Recovery: Review page is displayed. 9. Click Submit. The specified table is flashed back. The LogMiner Utility LogMiner is a utility that you can use to recover from user error failures. The LogMiner utility helps identify the changed records in redo log files by using PL/SQL procedures and functions. LogMiner uses the V$LOGMNR_CONTENTS data dictionary view to extract Data Definition Language (DDL) and DML operations from redo log files. The V$LOGMNR_CONTENTS data dictionary view contains DML statements for restoring the changes made to a database. LogMiner uses both online and archived redo log files to track the changes made to the database objects.
188 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Review Checklist: Performing Database Backup and Recovery: Oracle Database 10g Administration I Describe the types of database failures. Describe checkpoints, redo log files, and archived log files. Describe the flash recovery area. Describe the types of database backups. Describe how to back up control files. Describe how to create consistent, inconsistent, and incrementally-updated backups. Describe how to manage database backups. Describe how to recover from various types of failures, such as instance failures and user error failures.
189 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Taking the Test Strategies The Oracle Certified Associate, Professional, and Master credentials identify a standard of competence for entry-level and professional job roles that use Oracle products. Oracle's certification program is a recognized credential that signifies a proven level of knowledge and ability. With each level of certification, a higher benchmark of ability is set for greater opportunities and higher pay. The 1Z0-042 exam is a proctored exam, which may be taken at an Oracle University Training Center or an authorized Prometric testing center. Oracle Certification Roadmap The 1Z0-042 Oracle Database 10g: Administration I exam is required to acquire your Oracle 10g DBA OCA certification. For more information on this certification, visit http://education.oracle.com/pls/web_prod-plqdad/db_pages.getpage?page_id=47&p_org_id=1001&lang=US#1 . For details on the 1Z0-042 exam, see the objectives for the exam at http://education.oracle.com/pls/web_prod-plqdad/db_pages.getpage?page_id=41&p_org_id=1001&lang=US&p_exam_id=1Z0_042#3. An Oracle candidate should combine training with on-the-job experience. Many of the exam questions are based on real-world scenarios so hands-on experience with the software is vital. Registering for the Exam To register for the exam: http://education.oracle.com/web_prod-plqdad/plsql/show_desc.redirect?dc=D20040&p_org_id=&lang=&source_call= Or http://www.prometric.com Resources Because the exam is based on the Oracle Database 10g: Administration Workshop I instructor-led training, attending this course is the best preparation. However, if you are unable to attend this class or do not have access to the materials, you can use the Oracle 10g documentation on the OTN to prepare for the exam: http://www.oracle.com/technology/products/database/oracle10g/index.html
190 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
Test Day Strategies The most important test day strategy is be thoroughly prepared for the exam beforehand. You must know the material. Cramming the day of the exam is not a good strategy to use for any type of test, especially certification exams. General Tips •
Schedule your exam only after you are confident that you have mastered the subject matter.
•
Schedule your exam for a time of day when you perform at your best.
•
Eliminate all distractions from your testing area.
•
Allow four hours to complete the registration and exam.
•
Eat a light meal beforehand.
•
Review the number of questions and the question types carefully before starting the exam. Be careful not to bypass this option because you are in a hurry to finish.
•
Everything you do has time limitations, so do not let the pressure overwhelm you.
Oracle Database 10g: Administration I - Specific Tips •
Before starting the exam, review your short stack of reserved flash cards and personal study notes to remind yourself about terms, topics, and syntax that are likely to appear on the exam.
•
Determine how much time you are allotted to answer the questions. Do not spend too much time on a given question during your first pass through the exam.
Test Item Types The 1Z0-042 exam contains only multiple-choice items. While knowing the technical content for this exam is important to pass the exam, understanding the methodology of the item type and following a strategy of how to answer each type can mean the difference between passing and failing. Multiple-Choice Read each multiple-choice item with the intention of answering the item without the alternatives that follow. Focusing on finding an answer without the help of the alternatives will increase your concentration and help you read the question more clearly. Understand that multiple-choice items with round radio buttons require a single response, and multiplechoice items with square radio buttons require one or more responses. If more than one response is required, pay special attention to the “directive” sentence of the question (“Choose two. Each correct answer…..”). This will indicate whether the different responses are independent or corresponding, for example:
191 www.selftestsoftware.com
Oracle 1Z0-042 Study Guide
“Choose two. Each correct answer represents a portion of the solution.” When this directive is given, each of the correct responses, when taken together, will provide the desired result. Sometime each response will be a different, independent answer: “Choose two. Each correct answer represents a unique solution.” When this directive is given, each response can be used independently to provide the desired solution. In other words, there are two ways to achieve the same result. Use the process of elimination when you do not know the answer for sure. If the question has a single answer and four options are listed, eliminate two of these options quickly and make the decision between the two that remain. This increases your probability to 50/50. Another helpful methodology is to identify a likely false alternative and eliminate it. This elimination method is particularly helpful when the item requires more than one answer. When two very similar answers appear, it is likely that one of them is the correct choice. Test writers often disguise the correct option by giving another option that looks very similar. You can download a free demo, from our Web site, that mimics the types of questions that will appear on the exam. Sample questions do not cover all the content areas on the exam.
192 www.selftestsoftware.com
YOU’RE ALREADY SMART, WE HELP YOU BE SMARTER.
Thank You and Good Luck on your Exams! Thank you for purchasing a Self Test Software certification exam preparation product. Self Test helps you figure out what you know and gives you the answers to what you don’t – it’s the best way to prepare for your certification exams. For your upcoming exam and throughout your IT career, Self Test is the only tool you need to improve your IT IQ and succeed on exam day.
The Self Test Software Team
View more...
Comments