Professional Documents
Culture Documents
Volume 1
This document contains proprietary information. It is provided under a
license agreement containing restrictions on use and disclosure and is
also protected by copyright law.
All products and company names are used for identification purposes
only and may be trademarks or registered trademarks of their
respective owners.
Table of Contents Oracle 10g Database Associate
Checkpoint Process 57
Server Process 58
Processing a query 59
Processing an Update 60
Processing a transaction 61
Summary 62
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page iii
Oracle 10g Database Associate Table of Contents
Schedule 247
Review 248
DBMS_DATAPUMP Job 249
Job Execution 250
Job Activity 251
Summary and Log 252
SQL*Loader 253
Data File 256
Control File 257
Executing SQL*Loader 258
Control File Generation 259
Select Control File 260
Select Data File 261
Load Method 262
Load Options 263
Schedule 264
Review 265
Confirmation 266
Completion Report 267
Summary 268
Practice 9 269
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page vii
Oracle 10g Database Associate Table of Contents
V2: Page viii Copyright 2007 Jeremy Russell & Associates Ltd.
Table of Contents Oracle 10g Database Associate
0I
Oracle10g DBA Associate V2
Class Overview
ODBA10gDB-OCA--Intro-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
For full information regarding this exam, please refer to the latest information on the Oracle
Corporation website1.
1
http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=39
Lesson Summary
Introductions
Class Objectives
Course Structure
Suggested Class Structure
ODBA10gDB-OCA--Intro-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Lesson Summary
Introductions
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Class Objectives
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Course Structures
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Objectives
ODBA10gDB-OCA--Intro-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
Course Structure 1
Lesson Topic
1 Installing Oracle 10g
2 Oracle 10g Architecture
3 Creating an Oracle Database
4 Database Interfaces
5 Starting and Stopping Oracle
6 Tablespaces and Datafiles
7 Schema Objects
8 Undo Management
9 Data Administration
10 PL/SQL for DBA's
ODBA10gDB-OCA--Intro-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Course Structure 1
This class consists of a mix of lecture and guided lab sessions. Your instructor will advise you of the
locations of demo, lab and any solution files for your class.
Course Structure 2
Lesson Topic
11 Database Security
12 User Administration
13 Network Administration
14 Backup and Recovery Concepts
15 Database Backups
16 Database Recoveries
17 Lock Management
18 Automatic Maintenance
19 Performance Tuning
20 Q&A
ODBA10gDB-OCA--Intro-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Course Structure 2
This class consists of a mix of lecture and guided lab sessions. Your instructor will advise you of the
locations of demo, lab and any solution files for your class.
ODBA10gDB-OCA--Intro-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
ODBA10gDB-OCA--Intro-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
1
0
Installing Oracle 10g
ODBA10gDB-OCA-01-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
During the lesson, you will install Oracle 10g Release 2 Enterprise Edition and create a sample
database using the Oracle Universal Installer (OUI).
Objectives
ODBA10gDB-OCA-01-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
This lesson explains the installation of the Oracle10g Enterprise Edition software.
During the installation, you will use the Database Configuration Assistant (DBCA) to create and
configure a sample starter database.
After the installation has completed, the installed software and data files will be explored.
Starting Installation
ODBA10gDB-OCA-01-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Starting Installation
The Oracle software can be downloaded from the following URL:
http://www.oracle.com/technology/software/products/database/oracle10g/index.html
(Note that this URL may change during reorganisations of the Oracle website).
A version appropriate for your operating system should be selected from this page. At the time of
writing, the latest version available for download is Oracle 10g Release 2.
The downloaded file should be unpacked (use WinZIP or PKZip for Windows or gunzip/cpio for
Linux and Unix operating systems). The unpacked file will create a new directory (database)
containing the Oracle Enterprise Edition installation software.
Windows systems
For Windows XP systems, selected system policies must be enabled. To set these policies, carry out
the following procedure:
1) Login as Administrator (or an account with Administrator privileges).
2) Click the Start button and select the Run option.
3) In the command box, enter secpol.msc
4) Expand Local Policies > User Rights Assignment
5) Double-click Log on as a batch job.
6) Add your account to the selected users or groups list.
In addition, a Windows system must be configured with a static IP address. For systems that are
connected to a Dynamic Host Configuration Protocol system, you must install the Windows local
loopback adapter before installing Oracle.
To check if a loopback adapter is installed on your computer, run the command below:
If there is a loopback adapter installed, you would see a report that includes the network values for the
loopback adapter. e.g:
~
Ethernet adapter Local Area Connection 2:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft Loopback Adapter
Physical Address. . . . . . . . . : 02-00-4C-4F-4F-50
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Autoconfiguration IP Address. . . : 169.254.25.129
Subnet Mask . . . . . . . . . . . : 255.255.0.0
~
14. Right-click the connection that was just created. This is usually named "Local Area Connection
2". Choose Properties.
15. On the General tab, select Internet Protocol (TCP/IP), and click Properties.
16. In the Properties dialog box, click Use the following IP address and do the following:
a. IP Address: Enter a non-routable IP for the loopback adapter. Oracle recommends
the following non-routable addresses:
192.168.x.x (x is any value between 0 and 255)
10.10.10.10
b. Subnet mask: Enter 255.255.255.0
c. Record the values you entered, which you will need later in this procedure.
d. Leave all other fields empty.
e. Click OK.
17. Click OK.
18. Close Network Connections.
19. Restart the computer.
20. Add a line to the SYSTEM_DRIVE:\WINDOWS\system32\drivers\etc\hosts
file with the following format, after the localhost line:
IP_address hostname.domainname hostname
where:
IP_address is the non-routable IP address you entered in step 16.
hostname is the name of the computer.
domainname is the name of the domain.
For example:
Linux/UNIX systems
For Linux and Unix systems, it will be necessary to perform several operating system actions to allow
installation to proceed. These details vary between different operating systems and you should
consult the OS specific installation documentation for the latest specific information. Typical actions
include checking for optional OS packages, checking kernel parameters and creating Oracle OS
accounts and group accounts. A general guide to installing Oracle 10g on Linux is at:
http://www.puschitz.com/InstallingOracle10gOnSUSE.shtml#
DownloadingOracle10gSoftwareAndBurningOracle10gCDs
To install this software and optionally configure a default database (for any operating system), run the
Oracle Universal Installer by navigating to the database subdirectory and executing the setup
utility (for Windows) or runInstaller (for Linux/Unix).
For Linux operating system installations, you may need to specify the -ignoreSysPrereqs
command flag to bypass unnecessary prerequisite checks during installation.
Installation Welcome
ODBA10gDB-OCA-01-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Installation Welcome
Basic pre-requisites check
If Oracle database software had been installed on the system beforehand, the OUI may display a pre-
requisites check screen. If the pre-requisites are met, the Installer Welcome screen illustrated above is
shown.
Basic installation
The Welcome screen allows simple (almost one-click) installation and optional configuration of a
starter database. To use this option, select the Basic Installation radio button. To create a starter
database, enter the global database name (default value of orcl) which must be unique on the server
being used.
Leave the Installation Type as Enterprise Edition, the version of Oracle that includes all required
options. Alternatives include Standard Edition and Personal Edition.
Enter an initial Database Password, which will be used for all initial Oracle database administration
accounts. Click Next to continue and automatically install Oracle 10g.
Advanced installation
To perform a manual, advanced installation, select the Advanced installation radio button.This
option allows a number of configuration choices to be specified, including :
Separate passwords for DBA accounts
Database character sets and product languages for international use
Automated backup settings
Alternate storage options, including Automatic Storage Management
The remaining pages in this lesson refer mainly to advanced installation options.
ODBA10gDB-OCA-01-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Enterprise Edition (EE) Fully featured, high performance, multi-processor edition. Can
be extended with several options and add-on packs.
Standard Edition (SE) Licenced for a single server or cluster with up to four
processors. Optional Real Application Cluster (RAC)
support.
Standard Edition One (SE1) Limited to a maximum of two processors.
Express Edition (XE) Entry level database; limited to the following maxima:
4GB of data, 1GB of memory, 1 processor.
Free for deployment and development.
Oracle XE is a separate product and is not discussed further in
this class.
During initial installation, the OUI allows selection of the installation type required.
ODBA10gDB-OCA-01-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Multiple versions of the Oracle software can be installed concurrently on a single host system.
ODBA10gDB-OCA-01-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
ODBA10gDB-OCA-01-8 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Once the required password information has been entered and the installation checks have been
successful, the OUI displays a summary screen containing all installation options.
If this list is incorrect, click the Back button to return to the previous screen and make appropriate
corrections.
If the options shown are correct, click the Install button to begin the installation and configuration
process for the starter database.
Installation In Progress
ODBA10gDB-OCA-01-9 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Installation In Progress
During installation, several screens are displayed to indicate the progress of the software installation.
After the software installation is completed, the Database Configuration Assistant (DBCA) is
invoked to create the starter database. A separate DBCA window opens to display the progress for
the DBCA. During software installation, the DBCA copies a seed database provided on the
installation media to create a starter database.
<OracleHome>\Inventory\logs\installActionsYYYY-MM-DD_HH-MI-SSXX.log
<OracleHome>\db_1\cfgtoollogs\dbca\<SID>
When the database has been created, a confirmation screen is displayed. This confirmation screen
includes a warning regarding default passwords, which should be changed for production database
systems. This will be discussed in Lesson 3 (Database Creation) and Lesson 12 (User
Management). Click the OK button to complete the installation.
End of Installation
ODBA10gDB-OCA-01-10 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
End of Installation
A final confirmation screen is displayed showing URLs for managing the newly created starter
database. These tools are discussed in Lesson 4 (Database Interfaces) and used throughout the
remainder of this class.
Note the URLs displayed for the iSQL*Plus program and OEM controls. These default to:
iSQL*Plus http://<hostname>:5560/isqlplus
OEM http://<hostname>:1158/em
The port numbers may vary from the defaults shown if there are other services using these ports on
the installation server.
These URLs should be added to your browser favourite lists for easy reference.
iSQL*Plus URL:
http://localhost:5560/isqlplus
To complete the installation, select the Exit button and respond to the confirmation prompt.
Database Storage
ODBA10gDB-OCA-01-11 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Database Storage
The starter database will create subdirectories for file storage in the following location:
<oracleHome>/product/<version>/<db_home>/dbs
<oracleHome>/admin/<SID>
<oracleHome>/oradata/<SID>
Summary
ODBA10gDB-OCA-01-12 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Practice 1
ODBA10gDB-OCA-01-13 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Practice 1
Install the Oracle software as provided on your system paths and directory information will
be provided by your instructor. Please ask any questions that are necessary during the
installation procedure since this process takes a significant amount of time, the procedure
will execute more smoothly if you ask before committing to the installation!
Once the software has been installed, you should modify the environment for your account as
described below:
Windows
On your desktop, right-click My Computer and select Properties. Click the Advanced tab, then
the Environment Variables button.
In the Environment Variables dialog, click the User variables New button:
In the New User Variable dialog, enter the following information (see lab script file in
C:\Oracle10g\Labs\Ch01EnvVar.txt for an example which you can copy):
Variable name SQLPATH
Note that the variable value should begin with a period / full-stop!
Press the OK button three times, to close all three open dialogs.
On the Windows task bar, click the Start button and select the Run menu option. In
the Run dialog box, type the following command (to execute the provided script file :
An MS-DOS window will open and the specified script will be executed, to create a stored procedure
for easily displaying large tables using SQL*Plus. There should not be any error messages displayed
please ask your instructor for advice if there appears to be an error.
When instructed by the script, type exit and hit return to close the window.
UNIX / Linux
Using the vi editor, open the .profile script in your home directory.
$ export SQLPATH=.:/Oracle10g/Labs:/Oracle10g/Scripts
Save the file. Log out of your OS account, then log back in, to re-execute your modified profile.
When the shell prompt is displayed, enter the command shown below, to create a stored procedure for
easily displaying large tables using SQL*Plus.
File Systems
Explore the installed software and data files that have been created by the installation procedure.
2
0
Oracle 10g Architecture
ODBA10gDB-OCA-02-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
ODBA10gDB-OCA-02-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
After completing this lesson, you will understand the architecture of a typical Oracle system (on both
Windows and UNIX systems).
You will appreciate the memory and disk structures for a typical database installation.
You will also be aware of how these memory and disk areas co-operate to process SQL queries on
and updates to the database information.
Server Database 1
ODBA10gDB-OCA-02-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Software
Oracles RDBMS software is installed into a dedicated directory area
(the ORACLE_BASE directory). This directory will contain many
subdirectories. For Windows, this directory is set by the Oracle
Universal Installer (OUI) to C:\Oracle\product\release.
Typical subdirectories under ORACLE_BASE include
BIN - executable programs
database - default location for data files
rdbms - database setup scripts
sqlplus - interactive SQL tools
network - networking configuration files
For both Windows and UNIX systems, the PATH environment variable
must be set to include the ORACLE_HOME/bin directory
Database
For each database, the OUI creates a separate home directory under ORACLE_BASE. The name of this
directory is type_n, where type is either db for a database or client for a client only
installation and n is an optional sequence number.
Instance
For each database, the OUI creates a separate instance, a set of memory areas and processes for
managing communication between the memory and the database disk files.
On Windows systems, the instance is implemented as a single multi-threaded process. On UNIX
systems, an instance is implemented as multiple co-operating processes.
SGA
Database
Processes
Control Data Redo Log Parameter
Instance
ODBA10gDB-OCA-02-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Database
An Oracle database is the set of Oracle files that together make up the permanent storage area for your
user data (and control information used by the Oracle software).
Each database includes several datafiles that are initialised during database creation. Additional
datafiles can be added as required for new application requirements.
Instance
A database is managed by an Oracle instance, a pre-allocated block of memory together with several
processes or threads that manage the memory and data files.
Depending on the configuration of the server hardware, several instances may co-exist on a single
server. Alternatively, with the Oracle Real Application Cluster (RAC) option, a single database
may be managed by multiple instances executing on separate, inter-connected servers. RAC provides
both scalability and fail-safe processing for 24x7 application requirements.
RAC is not discussed in this class.
Database
ODBA10gDB-OCA-02-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Database
A database file set consists of multiple file types, including control files, data files, online redo log
files and a parameter file.
Control files - name and status of data and online redo log files
Data files - pre-allocated storage areas for system and user information
Online Redo Log files - transaction log files holding details of recent updates
Parameter files - configuration and tuning information for the instance
An optional password file is held outside the main data files, in order to authentic privileged user
operations.
Instance
ORACLE_SID
Instance : Memory and processes
Required to be started
for database access SGA
Instance is the only way Shared Buffer Java Pool
to access information Pool Pool Log Buffer
ODBA10gDB-OCA-02-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Instance
An instance must be started for each database that is required to be accessed. The instance is the only
permitted means of accessing information stored in the database. An instance consists of preassigned
memory areas and associated processes or threads.
An instance is identified by a unique system identifier, the ORACLE_SID.
On a Windows system, the ORACLE_HOME and ORACLE_SID settings are stored in the Windows
registry. For UNIX systems, the ORACLE_SID value should be set into an environment variable.
Memory Areas
An instance includes several memory areas, together called the System Global Area (SGA). The SGA
is used to manage data on behalf of multiple users (clients). Both memory allocation and initialisation
of background processes for the instance are performed automatically as the instance starts.
Processes
Additional optional processes may be started for other purposes, as discussed in later lessons. These
processes include:
Memory monitor (MMON) - collects statistics for Automatic Workload Repository
Memory manager (MMAN) - SGA memory broker to coordinates memory area resizing
Change tracking (CTWR) - track changed database blocks to speed backup processing
Queue monitor (QMNn) - coordinates the Oracle Advanced Queuing option
ODBA10gDB-OCA-02-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
The structures illustrated above are the absolute minimum required to start a new database and do not
represent a workable production system setup.
Users2 Payroll
Control
ODBA10gDB-OCA-02-8 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Parameter File
ODBA10gDB-OCA-02-9 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Parameter File
Two formats of parameter files are supported. A binary format (spfile) is the recommended format.
An alternate text file format (pfile) can be used for backwards compatibility with earlier Oracle
releases.
SPFILE
The spfile resides in a fixed location by default, typically the $ORACLE_HOME/dbs directory on a
**IX system. . (For Oracle10g Release 1 and older, and on Windows NT/2000 systems, the location
is %ORACLE_HOME%\database).
When using spfiles, dynamic) parameters can be modified with an ALTER SYSTEM command and are
therefore taken into account immediately. A SCOPE= argument to the ALTER SYSTEM command
accepts values of MEMORY, SPFILE or BOTH to indicate where changes are to be made.
PFILE
A static parameter file is a text file, usually copied from the Oracle sample provided and modified for
specific site requirements. Parameter files are also often called an initsid.ora file, or init file.
The init file is read during instance creation and startup; modifications to the parameters are not
refreshed until the next instance startup occurs.
If used, a PFILE is located in the same directory as the static file.
The default file name is initXXX.ora, where XXX is the system identifier (SID) assigned to the
database. Access to a PFILE is required from a remote system for startup of an instance.
The v$spparameter view contains current settings (Ch02ListParameters.sql).
Control File
Control
File
ODBA10gDB-OCA-02-10 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Control File
A control file is established when a new database is created, to hold the name and status of all other
files (except the parameter file) in the system. The file is a binary format and must be examined using
Oracle SQL statements.
The control file also stores information used by the Recovery Manager (RMAN) utility. This utility
performs (semi)-automated backup and recovery operations and is discussed in Lessons 14 through
16.
The control file is opened when an instance is started and must remain accessible and writeable for the
entire duration of the instance lifespan. Updates to status information are applied regularly to the
control during operational access.
Loss of a control file can mean that a database restore and recovery may be needed typically, this
involves loss of valuable data from the database. To guard against such occurrences, Oracle
recommend that the control file is mirrored. If a single mirrored file fails, the database instance will
shut down immediately but recovery is possible with no data loss, other than currently executing
transactions.
From Oracle 9i onwards, a feature called OMF (Oracle Managed Files) was introduced. The OMF
facility provides default names and locations for Oracle files, simplifying the creation and
management of control, redo log and data files.
The OMF name for a data file is ora_%u.ctl, where %u is a value to guarantee uniqueness.
To use OMF, the following optional initialisation parameters must be set:
DB_CREATE_FILE_DEST
DB_CREATE_ONLINE_LOG_DEST_1
DB_CREATE_ONLINE_LOG_DEST_1
Data Files
Data files
During database building, a database file (the SYSTEM file) is created to hold system information
(dictionary, system undo/rollback areas and more). For Oracle10g, a second required database file
(SYSAUX) is created to hold additional critical database information.
Each datafile belongs to a named database object called a tablespace. The tablespace unit is a
logical container for database objects. This structure allows physical files to be moved around the
system without affecting the logical structure of the database.
Other data files can be added to the system to hold different and additional information and logical
information (tables, indexes etc) can be mapped as required into the physical data files and parent
tablespaces.
Each data file has optional characteristics that permit the file to extend automatically when the file
runs out of space. Alternatively, a file can be manually extended by a DBA when required.
Datafiles are generally limited to a maximum size of under 2 GB by operating system restrictions.
There are few performance restrictions by creating maximum sized datafiles; however, administration,
backup and moving files is likely to be easier if the file sizes are limited to less than the maximum
possible size.
The OMF name for a data file is ora_%t_%u.dbf, where %t is the (truncated) tablespace name and
%uis a value to guarantee uniqueness.
Tablespace and file information is available from the dictionary view DBA_DATA_FILES
(V$DATAFILE) and DBA_TABLESPACES (V$TABLESPACE) respectively (Ch02ListDataFiles.sql).
Bigfiles
Oracle 10g provides an alternate storage format called a bigfile. A bigfile tablespace can only contain
a single datafile, that can be up to 128 terabytes in size (4 billion 32k data blocks).
Data Dictionary
Data Dictionary
The data dictionary is a group of tables and associated views that contain and track control
information about the database contents. Any required information can be accessed by sufficiently
privileged user accounts from the dictionary.
The underlying (base) tables are owned by the reserved SYS account. The tables reside in the
SYSTEM tablespace.
Public views are provided to decipher the internal information stored in these tables.
A master list of dictionary tables is held in the view DICTIONARY.
The majority of the dictionary information is provided
SQL> DESCRIBE dba_data_files
in three separate forms. Tables with the following Name Null? Type
prefixes contain the stated information: ----------------- -------- -------------
FILE_NAME VARCHAR2(513)
FILE_ID NUMBER
TABLESPACE_NAME VARCHAR2(30)
DBA : all object types these tables are visible BYTES NUMBER
to DBA accounts only BLOCKS NUMBER
STATUS VARCHAR2(9)
RELATIVE_FNO NUMBER
ALL : objects accessible to the logged in account AUTOEXTENSIBLE VARCHAR2(3)
MAXBYTES NUMBER
USER : objects owned by the logged in account MAXBLOCKS NUMBER
INCREMENT_BY NUMBER
USER_BYTES NUMBER
USER_BLOCKS NUMBER
Additional tables are provided for privileged accounts ONLINE_STATUS VARCHAR2(7)
ODBA10gDB-OCA-02-13 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Password File
ODBA10gDB-OCA-02-14 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Password File
An Oracle password file is an optional file, held outside the main database structure, and is used to
authenticate privileged users i.e. those that can start and stop the database instance.
A password file is created using the orapwd OS command, to hold a preset maximum number of
users. Default entries are added for the two Oracle standard users (SYS and SYSTEM). Further
entries can be added for additional users as required.
Without a password file, startup and shutdown is managed using operating system authentication i.e.
valid users are recognised by their OS login name. The precise method used varies therefore between
operating systems.
With a password file, startup and shutdown privilege is granted by a special login method discussed
later.
orapwd command
C:\>orapwd
Usage: orapwd file=<fname> password=<password> entries=<users> force=<y/n>
where
file - name of password file (mand),
password - password for SYS (mand),
entries - maximum number of distinct DBA and
force - whether to overwrite existing file (opt),
OPERs (opt),
There are no spaces around the equal-to (=) character.
C:\>
The V$PWFILE_USERS view shows the contents of the current password file (Ch02PWfile.sql).
Database
Segment
Extent
ODBA10gDB-OCA-02-15 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Each database consists of several physical data files, grouped into logical structures called
tablespaces. Data files and tablespaces are discussed in Lesson 6.
Database objects (tables, indexes) are positioned within a tablespace on creation. These and other
schema objects are discussed in Lesson 7
Each extent is a series of contiguous Oracle data blocks allocated to the segment as a unit.
The data block is the unit of I/O for the Oracle instance.
Blocks
ODBA10gDB-OCA-02-16 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Blocks
The size of the Oracle data block is fixed at database creation time and ranges from a minimum of 2k
to an OS dependent maximum (usually 32k or 64k). The default block size is set by the
db_block_size parameter file entry and is used for the SYSTEM, SYSAUX and any temporary
tablespaces.
Careful consideration must be given to the choice of default Oracle data block size, since this is not
possible to be changed without significant downtime after database creation. The data block size
selected may also severely impact ongoing performance of the database.
A data block may be (and usually is) larger than the underlying operating system block size. The data
block is the unit of I/O and is also the unit in which the size of the buffer cache is specified in the
parameter file.
From Oracle 9i onwards, multiple data block sizes can be supported in a single database. Up to four
additional block sizes can be specified for special purposes. Larger block sizes favour data
warehousing systems; smaller block sizes improve performance for OLTP systems.
Each block is dedicated to a particular type of storage (named table, index etc).
For tables, each block can hold multiple rows. If a row is deleted, the space is marked as reusable and
may be repopulated by further insert operations on the same table. The released space is not
automatically reclaimed by Oracle for other purposes.
Blocks can be configured to include spare (unused) space to allow for growth to existing objects.
This is discussed in Lesson 7 Schema Objects.
Extents
ODBA10gDB-OCA-02-17 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Extents
Extents are added automatically to a segment when it runs out of space. The DBA can manually add
extents on demand, subject to free tablespace extents being available.
Each object can have default storage parameters that control the growth rate (percentage) and
maximum allowed size of the object, subject to space being available in the containing tablespace.
Segments
ODBA10gDB-OCA-02-18 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Segments
The disk space used by a single object, including the area allocated on creation (the INITIAL extent)
and any subsequently allocated areas (the NEXT extents) makes up the SEGMENT for the object. A
segment resides within a single tablespace but can have allocated extents in any data file belonging to
the tablespace.
Data Segments
Each table in the database resides within a single segment, contained within one tablespace.
Partitioned tables can be spread across multiple segments, each of which can reside in separate
tablespaces.
Index Segments
Index (parallel structures to tables for fast access and sorting) reside in their own separate segments.
Index segments should be positioned in a separate tablespace to their associated table for maximising
performance and minimising contention. Index segments can also be partitioned if appropriate.
Temporary Segments
Temporary segments may be created for a SQL statement, when the space required for operations
such as sorting cannot fit inside allocated memory. In such cases, temporary segments are assigned in
dedicated areas for the duration of the statement.
Rollback/Undo Segments
Rollback/Undo segments hold images of database blocks prior to updates being applied, for use in the
event that a statement needs to be undone (rolled back). Rollback segments are created automatically
at database creation in the SYSTEM tablespace.
In Oracle 10g, undo segments, an enhanced mechanism, are used for regular transactions. Further
details are discussed in Lesson 8.
Memory Structures
SGA
Shared Buffer Java Pool
Pool Pool Log Buffer
Large Pool
Memory Structures
Oracle reserved memory is allocated at instance startup time and released as the instance stops.
The main area is termed the SGA (shared global area) and consists of several distinct sub-areas.
Initial memory allocations are controlled by the SGA_TARGET parameter, which is set to the total
desired size of memory to be used by an instance. This dynamic parameter can be altered whilst an
instance is running. More information is discussed in Lesson 19, regarding the Memory Advisor and
Automatic Shared Memory Management.
Memory in the SGA is managed in units of a granule. A granule is either 4MB (for total SGA size of
128MB or less), otherwise a granule is 16MB.
Shared Pool
SGA
Shared Buffer Java Pool
Pool Pool Log Buffer
Large Pool
ODBA10gDB-OCA-02-20 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Shared Pool
The shared pool area is used to hold recently accessed SQL and PL/SQL statements and dictionary
information describing objects referenced by the cached statements.
The library cache holds both original and parsed SQL & PL/SQL statements. The shared area where
they are held includes the statement text, the compiled version of the statement (the parse tree) and the
execution plan (the break down of the steps to execute the statement block).
Statements already resident in memory can be shared under the control of the Oracle optimiser and
this enhances performance by reducing the requirement for re-parsing/re-compiling statements.
The dictionary cache holds the definitions of database objects used in conjunction with cached
statements. If the server cannot find the required information in the cache, the details are (re) loaded
from disk as required.
A single (shared_pool_size) parameter can be used to the size of this area the minimum
permitted value is 2MB and a more common production system value might start from around 50MB
or more.
Buffer Cache
SGA
Shared Buffer Java Pool
Pool Pool Log Buffer
Large Pool
ODBA10gDB-OCA-02-21 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Buffer Cache
The database buffer cache is the memory repository for holding database bocks and making them
available to server processes/user processes for presentation.
Server processes will load data blocks until the area is full, after which blocks may be overwritten if
clean. The DBWR process writes amended (dirty) blocks back to the database when space begins to
run out.
A least recently used (LRU) algorithm is used to identify blocks that can be aged out (written back)
when required.
For manual configuration, the size of the buffer cache is controlled by the parameter
DB_BLOCK_BUFFERS,which specifies how many blocks of DB_BLOCK_SIZE are to be used for this
memory area.
Keep/Recycle Caches
Two additional reserved areas can be defined, the KEEP and RECYCLE cache. These areas have
the same block size as the main db_block_size value. Objects (tables and indexes) can then be set
to use these cache areas.
Large Pool
ODBA10gDB-OCA-02-22 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
The Redo Log Buffer is a memory area used by DBWR to record details of changes to data blocks by a
transaction.
The block address, the change position and the new value are recorded automatically.
The single log buffer is used by all concurrent transactions, therefore changes by multiple user
processes can be interleaved.
The frequent writing of the contents from the log buffer to the log file by the LGWR helps to ensure
continued integrity of the database contents. If the log buffer becomes full, processing halts for all
users until the log writer frees sufficient space to continue.
Process Structure
SGA
LGWR
DBWR SMON
CKPT
PMON SERVER
Processes
ODBA10gDB-OCA-02-23 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Process Structure
A running Oracle instance uses several processes to manage the user interaction. The physical
process structure varies by operating system.
Processes may be user or system processes. All system processes are executed on the same processor
as where the database resides any network communication is performed from the server processes to
the shadow process.
Windows (NT/2000) run all Oracle processes as threads within a single Windows process Windows
inter process communication (IPCS) is not ideally suited to the speed requirements of Oracle.
Most UNIX systems spawn separate physical OS processes, which can be uniquely identified using a
ps ef or ps aux OS command.
Each process has an assigned Program Global Area (PGA). This memory is either private or shared,
depending on the selected networking method.
User processes may run on the same or a different host from the database server processes. Further
details of Oracle Networking are discussed in Lesson 13.
LGWR
DBWR SMON
CKPT
PMON SERVER
Processes
ODBA10gDB-OCA-02-24 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Database Writer
The DBWR process is responsible for cleaning the buffer cache by writing dirty blocks back to the data
files. These blocks may include live data blocks or undo/rollback segment blocks.
DBWR is responsible for keeping a number of free blocks in the buffer cache memory to allow new data
to be read without delay. Server processes making changes in memory rely on space being available
DBWR runs in the background to avoid a performance penalty on the user front-end processes.
One (or more) DBWR processes are configured to batch up changes to the database files and write them
efficiently when one of a number of events occurs:
Multiple database writer processes can be started using the db_writer_processes parameter.
LGWR
DBWR SMON
CKPT
PMON SERVER
Processes
ODBA10gDB-OCA-02-25 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Log Writer
LGWR writes from the redo log buffer to the log files on disk:
The actions of the log writer are essential for ensuring transaction integrity in the event of a recovery
becoming necessary.
If redo logs have been multiplexed, and one of the log files cannot be written, LGWR writes to other
members of the group and records an error in the system alert log.
If all online members of a log group are unavailable for writing, LGWR prevents further processing for
the entire instance until the fault is cleared.
LGWR
DBWR SMON
CKPT
PMON SERVER
Processes
ODBA10gDB-OCA-02-26 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
System Monitor
SMON performs management functions during startup of the database instance, to automatically recover
a system in the event of an improper shutdown. Incomplete transactions are undone (rolled back) and
data in the log files that has not reached the data files is applied. The effect during this FAST
RECOVERY phase is to ensure that all committed transactions and only committed transactions are
recorded in the data files.
The procedure ensures that all data files represent a consistent view of the data and that this consistent
view/status is recorded in the control files.
Different versions of Oracle handle this process with varying degrees of speed to open the database.
After an instance is running, SMON is responsible for managing deallocated disk space by shadow
processes, by coalescing them into more usable space and for policing the other processes by
controlling their timeout intervals.
LGWR
DBWR SMON
CKPT
PMON SERVER
Processes
ODBA10gDB-OCA-02-27 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Process Monitor
The PMON process periodically confirms that all shadow processes are still active.
For dead processes, PMON performs a clean up on their behalf by unlocking updated blocks and rolling
back pending changes.
All effects and changes of a failed transaction are therefore removed from the instance.
Checkpoint - CKPT
SGA
LGWR
DBWR SMON
CKPT
PMON SERVER
Processes
ODBA10gDB-OCA-02-28 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Checkpoint
The checkpoint process CKPT manages writing of updated information back to data files.
Periodically, a checkpoint event occurs. During the event, CKPT coordinates with the database writer
to write changed data blocks from the buffer cache back to the data files.
This process also writes checkpoint control information to both the control files and individual data
file headers.
Server Process
SGA
LGWR
DBWR SMON
CKPT
PMON SERVER
Processes
Server Process
As a user process connects to an instance, a server process is started and a Program Global Area
(PGA) is assigned.
The shared pool is checked for the presence of the same statement. If the query does not exist in the
pool, the text of the statement is compiled into an execution plan and placed into a shared pool area.
The server statement processes the compiled plan and retrieves the required blocks into the buffer
cache.
If the user issues an update statement, the server process will make the required changes to blocks in
the buffer cache.
Processing a query
Large Pool
Locate blocks
Processes
Read into DBWR LGWR SMON
cache
PMON CKPT SERVER
Return copy to ARCH
user Instance
ODBA10gDB-OCA-02-30 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Processing a query
1. The user process issues a SQL statement to retrieve information.
2. The statement is passed to the shadow process, which confirms whether the same statement is
already in the library cache and parses/compiles a new version if required.
3. The shadow process then checks for the required blocks in memory This may also trigger
activity by DBWR to clean sufficient blocks for the new read operation.
4. If the required blocks are not in memory, the server initiates a read from the data file(s) into
the buffer cache.
Processing a update
Large Pool
buffer cache
Processes
Write change
DBWR LGWR SMON
vectors to log
PMON CKPT SERVER
Update undo
ARCH
Instance
ODBA10gDB-OCA-02-31 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Processing an Update
1. If the blocks to be changed are not already in memory, the shadow process initiates a read
(and possibly action by DBWR to clear sufficient space).
4. Before image information is also written by the shadow process to separate rollback segment
blocks.
Processing a transaction
Large Pool
log buffer to
disk Processes
DBWR LGWR SMON
User advised of
successful PMON CKPT SERVER
commit ARCH
Instance
ODBA10gDB-OCA-02-32 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Processing a transaction
1. When a commit statement is issued by a user process, the shadow process indicates that by
writing a commit flag to the redo log buffer.
2. LGWR empties the log buffer note that this may include information for other active
transactions that have not committed yet i.e. Oracle is performing a write ahead.
3. The user process receives a successful commit message after step 2 completes and
information has been physically written to disk.
4. The server process then releases all locks on updated resources and waits for another SQL
statement from the user process.
Summary
ODBA10gDB-OCA-02-33 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Practice 2 - Questions
1. The DB_BUFFER_SIZE parameter controls the size of the Oracle data block cache?
a. False
b. True
2. Extents for an object can reside in any data file assigned to the database.
a. True
b. False
3. Operating system editors can be used to change control files.
a. True
b. False
4. Archive processes are recommended for test systems to speed non-essential operations.
a. False
b. True
5. The buffer cache is a dynamically resizable area without restarting the database.
a. False
b. True
6. A large log buffer is better for system performance.
a. True
b. False
7. Archive destinations are limited to a single destination.
a. False
b. True
8. An update always writes data immediately to the data files.
a. True
b. False
9. The SMON process monitors the system for failed user processes.
a. False
b. True
10. A data file cannot grow once it has been created
a. True
b. False
Practice 2 - Answers
1. DB_BUFFER_SIZE parameter controls the size of the Oracle data block cache?
a. False the size is controlled by DB_CACHE_SIZE
a. True
2. Extents for an object can reside in any data file assigned to the database.
b. True although there are some restrictions on certain data file contents.
c. False
3. Operating system editors can be used to change control files.
a. True
b. False control files are in a binary format and must be altered using SQL.
4. Archive processes are recommended for test systems to speed non-essential operations.
a. False however, the ARCH process is recommended for production systems.
b. True
5. The buffer cache is a dynamically resizable area without restarting the database.
a. False
b. True the use of Automatic Shared Memory Management is preferred.
6. A large log buffer is better for system performance.
a. True
b. False a large log buffer will delay writing transaction information to the disk.
7. Archive destinations are limited to a single destination.
a. False up to ten archive destinations can be specified if required.
b. True
8. An update always writes data immediately to the data files.
a. True
b. False writes performed by the DBWR are delayed for an indeterminate period.
9. The SMON process monitors the system for failed user processes.
a. False this is performed by PMON. The SMON process has other purposes.
b. True
10. A data file cannot grow once it has been created
a. True
b. False a data file can be manually or automatically extended, or manually shrunk.
3
0
Creating a Database
ODBA10gDB-OCA--03-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
ODBA10gDB-OCA--03-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
This lesson demonstrates the use of the Database Configuration Assistant for the following tasks:
Creating a new database
Altering an existing database configuration
Deleting a database
Creating and managing database templates
Starting DBCA
ODBA10gDB-OCA--03-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Starting DBCA
The Database Configuration Assistant (DBCA) is started from a command line window using the
command dbca.
Alternatively, select Start > Programs > Oracle Home > Configuration and Migration Tools >
Database Configuration Assistant.
DBCA is used to create new databases, reconfigure a restricted set of database parameters, delete an
existing database and manage (add, modify or delete) templates for creating further new databases.
DBCA Operations
ODBA10gDB-OCA--03-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
DBCA Operations
After an initial welcome screen, DBCA presents the following options in step 1:
Create a Database This option creates new databases, configures networking
options and starts the new database instance.
Configure Database Options Selected global system parameters can be changed on
existing databases using this options; examples include the
networking option used to connect to the database.
Delete a Database Shut down a running instance and remove all database
files permanently. Additional passwords are required for
this purpose.
Manage Templates Allows the creation, amendment and removal of the
templates upon which new database creation is based.
When multiple similar databases are to be created, the use
of templates provides a faster method for duplicating
database setup.
Templates can also be save for reuse after completing the
database creation process using DBCA.
Configure Automatic Automatic Storage Management (ASM) is an Oracle
Storage Management RAID equivalent mechanism for managing large
databases. ASM is not discussed in detail in this class.
For more information, please refer to the Oracle Database
Administrator class (Part 2).
ODBA10gDB-OCA--03-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Custom Database This option offers the most flexibility when creating new
databases. Use this option for creating a new template from
scratch or where there are particular requirements for new
database configuration.
Data Warehouse Creates a new database which will be used for applications that
will need to support complex queries involving many tables
being joined for reporting and forecasting operations.
General Purpose Where the intended use of the database is not known, or if both
online transaction processing (OLTP) and data warehouse
applications are to be supported.
Transaction Processing For environments where 24/7 operations are required and there
will be a large number of short transactions, this option should
be used to configure an appropriate instance.
Once a database has been created, the DBA can fine-tune almost any template-derived parameter for
optimum speed and / or throughput.
Database Identification
ODBA10gDB-OCA--03-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Database Identification
Step 3 of the DBCA requires the following database identification parameters:
Global Database Name A unique database name, consisting of the database SID appended
with a domain name. If you do not have a specific domain to use, the
default .world can be specified if required.
System Identifier (SID) The SID must be unique on the server upon which the instance resides.
The SID setting is used in the Oracle Networking files (discussed in
Lesson 13) to associate a connection string from a remote client with a
specific instance and set of database files.
Management Options
ODBA10gDB-OCA--03-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Management Options
In Step 4 of the DBCA, the preferred option for managing the database by a DBA is selected. Two
mechanisms are provided by Oracle, Grid Control and Database Control.
Grid Control
Grid Control allows the management of multiple databases, together with other Oracle resources.
Grid Control must be pre-installed (if required) on a middle-tier server before creating a database
with the DBCA the Grid Contol and Grid Control Agent are provided on a separate CD in the
Oracle installation kit. If the DBCA detects an optional Grid Control Agent service running on the
server, the Grid Control option button is enabled and the required Agent Service to be used with
the database can be selected from the drop-down list. Further details of Grid Control are not
covered in this class.
Database Control
The Database Control can be used in a standalone environment without any additional software
installation. Database Control provides similar management features as Grid Control, for a single
database instance. This screen also permits the entry of e-mail information (server and destination
address) for automated status messages. Automatic daily backups to a Flash Recovery Area
(FRA) can also be enabled (discussed on page 79 and in Lessons 14 through 16).
To enable automated backups, you must specify a operating username and password for a member
of the ORA_DBA group or an Administrator/Superuser account.
Both Grid Control and Database Control management options provide a web-based management
mechanism for controlling a database.
Database Credentials
ODBA10gDB-OCA--03-8 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Database Credentials
The DBCA wizard, step 5, allows the passwords for the initial administration accounts to be specified.
It is important to set secure passwords for all these critical accounts. During step 5 of the wizard, the
option to use the same default password can be selected.
A later step, invoked at the end of the new database creation procedure, can be used to set these and
other account passwords (discussed on page 89).
Storage Options
ODBA10gDB-OCA--03-9 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Storage Options
Wizard Step 6, Storage Options, can be used to select the storage method to be used for data files,
control files and redo log files. Oracle 10g provides the following choices:
File System In this database, files will be created in the regular file system. Each
file will therefore have a user assigned name and location or, if Oracle
Managed Files (OMF) is used, files will be named and located
according to Oracle specified rules.
More details on the OMF mechanism is discussed on page 78 and in
Lesson 6.
Automatic Storage Automatic Storage Management is the Oracle RAID replacement
Management (ASM) mechanism. ASM is not recommended for Windows environments.
ASM requires a dedicated ASM instance, which is used to manage
large disk areas in which Oracle controls the software RAID
compatibility.
ASM is not discussed in detail in this class. For more information,
please refer to the Oracle Database Administrator class (Part 2).
Raw Devices For Oracle Real Application Cluster (ORAC) installations, where a
cluster file system is not available, raw devices can be used to bypass
the OS file system structure.
ODBA10gDB-OCA--03-10 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
The File Location Variables button displays a list of the pre-defined environment variables used by
the DBCA. The current settings of the preset variables cannot be altered at this stage, but additional
variables can be specified to override and extend the available variables if required.
In all cases, a further wizard step allows selective overriding of the options selected here see page
85.
Recovery Configuration
ODBA10gDB-OCA--03-11 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Recovery Configuration
Wizard Step 8 allows specification of a range of recovery options, for use in the event of catastrophic
database failure.
Archiving
The optional archiving mechanism runs additional processes to copy (archive) the contents of filled
log files during production running. The archived logs are required in the event of a media failure or
user error that necessitates recovery of part of the database content.
Archiving is strongly recommended for use in production database systems. This feature should be
enabled once the initial database has been built and is ready for production use. If the feature is
enabled during database creation, the time and disk space required to create the database will be
extended without good reason.
If archiving is enabled and flash recovery disabled, the Edit Archive Mode Parameters button can be
used to change the default archive log name and location(s).
Archiving is described in detail in Lessons 14 through 16.
Database Content
ODBA10gDB-OCA--03-12 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Database Content
The Oracle installation CD contains sample schemas for demonstrating various mechanisms using
SQL and other features in Oracle. These schemas contain the data used in the Oracle manuals and
sundry tutorials.
For production systems, the sample data is not generally required and therefore should not be selected.
If the Sample Schema checkbox is checked, approximately 130MB of additional space is required to
load the sample data.
The Custom Scripts tab can be selected to run additional user-written scripts during database
creation. Browse to the location of the required script and add to the Script Name box if required.
ODBA10gDB-OCA--03-13 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
ODBA10gDB-OCA--03-14 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Block Size
The Block Size value is used for SYSTEM, SYSAUX, UNDO and TEMP tablespaces. The default selected
(8k) is suitable for the majority of Oracle databases. When using any of the predefined templates, this
value cannot be changed.
Additional tablespaces can be created with different (larger) block sizes for special purposes (see
Lesson 6).
Processes
The Processes value specifies the maximum number of Oracle processes that can connect to the
database. Allowances must be made for background processes and parallel execution processes in
addition to regular user processes.
This parameter can be tuned once the database instance is operational.
ODBA10gDB-OCA--03-15 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
For more information on choosing a National Character Set, see the Oracle Database Globalization
Support Guide
ODBA10gDB-OCA--03-16 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Dedicated Server Mode Connects using a separate server process for each client; this
mode is appropriate for long running data warehousing
transactions and when the total number of connections is
anticipated to be low.
Shared Server Mode Previously called Multi-threaded server (MTS), this mode
shares server processes between multiple clients. Shared
servers are appropriate for OLTP applications, web-connected
databases and similar systems with a relatively high
connection level.
ODBA10gDB-OCA--03-17 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Creation Options
ODBA10gDB-OCA--03-18 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Creation Options
In Step 12 of the DBCA wizard, the following operations are available:
Create Database Use the entered information in the Wizard to create a new
database. The summary dialog illustrated on the next page
shows the options selected.
Save as a Database Template Saves the entered information in the form of a new template,
which will be added to the list of available templates provided
by Oracle.
A new name and description should be entered to identify the
new template.
Generate Database Creation Saves the entered information as a set of new SQL scripts in a
Scripts user-selectable location.
If this option is chosen, the scripts can be executed using
SQL*Plus (see lesson 4). Networking configuration, Oracle
services for Windows NT/2000/XP and ORATAB entries for
Solaris will need to be configured manually following
database creation.
Confirmation
ODBA10gDB-OCA--03-19 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Confirmation
Prior to new database creation, an summary page as shown on the slide is presented. This information
can be saved in the form of an HTML file, in a user-selectable location. The saved page should be
printed and filed for future reference.
Select the OK button on this confirmation screen to begin the database creation process.
ODBA10gDB-OCA--03-20 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
<ORACLE_BASE>\product\10.2.0\<ORACLE_HOME>\cfgtoollogs\dbca\<SID>
Password Management
ODBA10gDB-OCA--03-21 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Password Management
Following successful database creation, the Password Management button can be used from the
DBCA summary screen to display a list of user account names.
For each account, the password can be set individually and required accounts can be unlocked to
allow login using the account details.
More information is discussed in later lessons in this class.
ODBA10gDB-OCA--03-22 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Delete a Database
ODBA10gDB-OCA--03-23 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Delete a Database
For existing and running databases, the Delete a Database radio button can be used to display a list
of databases. Select the database instance to be deleted and click Next. Respond to the alert dialog
and to any username/password prompts that are displayes.
You must specify a privileged DBA connection in order to delete a database.
Note that this operation is NOT easily reversible.
Templates
ODBA10gDB-OCA--03-24 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Templates
Database templates are stored XML scripts that can be used for creating new databases.
DBCA is installed with three pre-defined templates and the ability to create a new custom template
from scratch.
Templates can be created as below:
From an existing Copy and modify an existing template.
template
From an existing Create a template from an existing database but do not copy the content,
database (structure only) just the physical structure. User schemas are not replicated.
From an existing Create a template from an existing database that duplicates (clones) the
database (structure and entire database structure and content.
data)
See page 93 for more details about creating new templates.
Deleting a Template
Unwanted or obsolete templates can be deleted. This includes the Oracle supplied database templates.
Template Properties
ODBA10gDB-OCA--03-25 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Template Properties
By selecting a template creation option from the Template Management screen, relevant DBCA
wizard pages are displayed to allow the template or database selected as the base for the new template
are displayed.
Any required template property can be modified by entering the required value in the wizard.
Template Confirmation
ODBA10gDB-OCA--03-26 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Template Confirmation
Once the required options have been modified, click the Finish button to save the modified template
and generate the starter database files.
Summary
ODBA10gDB-OCA--03-27 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Practice 3
ODBA10gDB-OCA--03-28 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Practice 3
In this practice, you should create a second database called DB2
Configure the new database for general purpose use and select the File System option for locating
data, control and redo log files.
The majority of other offered defaults will be acceptable.
Your instructor will provide further details and instructions that are appropriate for your training
environment during the practice.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
4
0
Database Interfaces
ODBA10gDB-OCA--04-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
ODBA10gDB-OCA--04-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
This lesson examines the interactive SQL interfaces provided with the Oracle 10g database. Concepts
demonstrated include:
Using SQL*Plus and iSQL*Plus to access the database and examine database structures.
Basic SQL statements for retrieving and modifying database content
A brief overview of commands used to manage structures and control transactions.
The highlights of using Oracle Enterprise Manager for DBA tasks is discussed.
22
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
ROW
ROW
7369 SMITH CLERK 7902 17-DEC-80 800 800 20
ODBA10gDB-OCA--04-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Interfaces - SQL*Plus
ODBA10gDB-OCA--04-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Interfaces SQL*Plus
Oracle 10g is delivered with two versions of the SQL*Plus tool
Windows Version
For Windows operating systems only, a GUI version of SQL*Plus is provided. This can be installed
on Windows systems from a separate Oracle Client CD, to enable remote access to UNIX/Linux
database. The Windows system will need to be configured for network access to the remote database.
This is discussed in a later lesson.
All versions of SQL*Plus accept the same command syntax, both for SQL commands to be executed
against the database and for control commands to modify the runtime environment.
V2: Page 100 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
Interfaces - iSQL*Plus
ODBA10gDB-OCA--04-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Interfaces iSQL*Plus
Oracle 10g is also delivered with a browser based version of SQL*Plus, called iSQL*Plus.
To execute iSQL*Plus, open a browser and enter the URL provided during database creation into the
browser address bar. The default address is:
http://localhost:5560/isqlplus/
Note that the port number (5560 as above) may vary depending upon other databases and TCP/IP
services running on the database server.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 101
Oracle 10g Database Associate Lesson 4 Database Interfaces
Connecting to a Database
Username
Password
Connect Identifier
ODBA10gDB-OCA--04-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Connecting to a Database
Several items of information are required to connect to a database:
User name A valid account that has been created in the database, with sufficient
permission to log in to the system.
Host String / Identification string used to locate the database server and instance.
Connect Identifier For remote access, this string needs to be entered into an Oracle
Networking configuration file, as discussed later in this class.
For connecting to an Oracle instance using a command line tool, the account name, password and host
string are specified as illustrated below:
user/password@host_string
scott/tiger@orcl
For the GUI tools, enter the required information on the displayed screen dialog. Click the OK or
Login button to continue.
V2: Page 102 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
SELECT
SELECT empno,
empno, ename,
ename, job
job
FROM
FROM emp;
emp;
SELECT
SELECT ** FROM
FROM emp
emp
WHERE
WHERE job
job == 'SALESMAN';
'SALESMAN';
SELECT
SELECT ** FROM
FROM members
members
WHERE
WHERE job
job == 'SALESMAN'
'SALESMAN' AND
AND hiredate
hiredate >> '01-JAN-85'
'01-JAN-85'
ORDER
ORDER BY
BY hiredate
hiredate DESC;
DESC;
ODBA10gDB-OCA--04-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
14 rows selected.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 103
Oracle 10g Database Associate Lesson 4 Database Interfaces
SELECT statement
Example statement
SELECT
SELECT empno,
empno, ename,
ename, job
job
FROM
FROM emp
emp
ORDER
ORDER BY
BY ename
ename
ODBA10gDB-OCA--04-8 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Database Credentials
SELECT <columnList | *> Required
lists one or more columns to be retrieved.
FROM <tableList> Required
where the information is to be retrieved from
(SQL isnt *that* smart!)
[WHERE <searchCondition>] Optional
controls which rows are retrieved. If the clause is omitted,
then all rows from the named table are returned.
[GROUP BY <groupColumns>] Optional
request that SQL summarises all rows having the same
information in the grouped columns.
[HAVING <groupCondition>] Optional
restricts the groups to be displayed.
[ORDER BY <sortColumnList>] Optional
requests a list of results in a specified order. If omitted, results
are presented in no particular sequence. The same statement
may produce different sequences if executed a second time; the
sequence depends on external factors.
.
V2: Page 104 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
Accessing Information
ODBA10gDB-OCA--04-9 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Accessing Information
When a SELECT statement is processed, the database server will retrieve the required rows and
columns and return these to the interface process for presentation.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 105
Oracle 10g Database Associate Lesson 4 Database Interfaces
ODBA10gDB-OCA--04-10 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
In common with other relational database products, the Oracle Server creates and manages a data
dictionary, consisting of a number of read-only tables that describe the content and structure of the
database.
Tables that are accessible to the current user can be further examined using the SQL*Plus DESCRIBE
statement. As with other SQL*Plus commands, this keyword can be abbreviated to the short version
DESC.
V2: Page 106 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
Choosing Columns
SELECT
SELECT empno,
empno, ename,
ename, job
job
FROM
FROM emp;
emp;
ODBA10gDB-OCA--04-11 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Choosing Columns
In the SELECT clause, you may include a list of the column names you want to retrieve, separated by
comma's.
An entire set of columns from the table can be retrieved by using the syntax '*' in place of the column
list.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 107
Oracle 10g Database Associate Lesson 4 Database Interfaces
Choosing Rows
SELECT
SELECT ** FROM
FROM emp
emp
WHERE
WHERE job
job == 'SALESMAN';
'SALESMAN';
ODBA10gDB-OCA--04-12 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Choosing Rows
In the optional WHERE clause, you may specify a list of conditions that each row in the listed table.
WHERE clause conditions can use a variety of relational operators, as well as LIKE (for wildcards),
BETWEEN (for range searchs) and IN (for list searches).
An entire set of rows from the table can be retrieved simply by omitting the WHERE clause.
V2: Page 108 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
Joining tables
SELECT
SELECT ename,
ename, dname
dname
FROM
FROM emp,
emp, dept
dept
WHERE
WHERE emp.deptno
emp.deptno == dept.deptno;
dept.deptno;
ENAME DNAME
SMITH RESEARCH
ALLEN SALES
WARD SALES
~ ~
ODBA10gDB-OCA--04-13 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Joining Tables
Tables in the database can be joined - linked together to retrieve information from more than one table
simultaneously.
A database designer will create tables to conform with the 'golden rules' of database design,
normalisation, according to the original design goals of the RDBMS technology.
The rule of 1NF (First Normal Form) encourages the database designer to remove repeated (multiple)
values to a second table. This provides more effective storage with an additional cost to retrieve the
original information.
The trade off between reduced storage needs and additional processing power to retrieve the
information is acceptable.
The entire set of columns and rows from the joined tables can be retrieved simply by omitting the
WHERE clause that links thetables together. Typically, this is neither logical nor desirable. A JOIN
CONDITION should be added to the WHERE clause to specify how the tables actually relate (join).
Oracle 10g supports other join options that conform to the ANSI SQL:99 standard. For more details,
please refer to the Oracle documentation.
.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 109
Oracle 10g Database Associate Lesson 4 Database Interfaces
ODBA10gDB-OCA--04-14 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
V2: Page 110 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
Insert Select
INSERT
INSERT INTO
INTO research_employees
research_employees
SELECT
SELECT ** FROM
FROM emp
emp WHERE
WHERE deptno
deptno == 20
20
Multi-table insert
INSERT
INSERT ALL
ALL
WHEN
WHEN job
job == 'MANAGER'
'MANAGER' THEN
THEN
INTO empman
INTO empman
WHEN
WHEN job
job == 'SALESMAN'
'SALESMAN' THEN
THEN
INTO
INTO empsales
empsales VALUES
VALUES (empno,
(empno, ename,
ename, sal
sal ++ comm)
comm)
ODBA10gDB-OCA--04-15 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
A multi-table insert can be carried out using the INSERT ALL statement. Rows from a base table can
be inserted into several tables conditionally.
Several other variations of this command are possible these include an unconditional INSERT, a
conditional FIRST INSERT and a pivoting INSERT.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 111
Oracle 10g Database Associate Lesson 4 Database Interfaces
Update merge
MERGE
MERGE INTO
INTO job_history
job_history JJ
USING
USING emp_history
emp_history EE ON
ON (( J.empno
J.empno == E.empno)
E.empno)
WHEN
WHEN MATCHED
MATCHED THEN
THEN
UPDATE
UPDATE SET
SET avsal
avsal == avsal
avsal ++ e.sal,
e.sal, cnt
cnt == cnt
cnt ++ 11
WHEN
WHEN NOT
NOT MATCHED
MATCHED
INSERT
INSERT VALUES
VALUES (empno,
(empno, avsal,
avsal, 1)
1)
ODBA10gDB-OCA--04-16 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
UPDATE [schema.]table
SET columnName = value [, columnName = value, ...]
[WHERE condition]
The Oracle MERGE statement can also be used as shown below. This command can either insert rows
(where no matching row exists in the target table) or update existing rows (where a match is found).
Further details on the MERGE statement are described in Lesson 9 Data Management.
V2: Page 112 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
TRUNCATE TABLE
Single statement transaction
TRUNCATE
TRUNCATE TABLE
TABLE job_history
job_history REUSE
REUSE STORAGE
STORAGE
ODBA10gDB-OCA--04-17 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
.
If the WHERE clause is omitted, every row in the table is deleted.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 113
Oracle 10g Database Associate Lesson 4 Database Interfaces
ODBA10gDB-OCA--04-18 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
A transaction is equivalent to a business unit of work all statements within a transaction must
complete together or be cancelled as a unit.
Oracle client processes are always operating within a transaction context. A new transaction is started
as a client process is run. Terminating a transaction automatically begins a new transaction.
Within a transaction, any modified rows are private to the transaction until it ends successfully.
DDL (CREATE, ALTER, DROP and TRUNCATE) statements implicitly commit any in-progress
transactions.
V2: Page 114 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
ODBA10gDB-OCA--04-19 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Transactions are confirmed with the COMMIT statement and cancelled with the ROLLBACK
statement.
If the transaction is cancelled, any changes made within the transaction are reversed.
Modified rows cannot be viewed or further modified by other concurrent transactions until the
modifying transaction completes.
If a client process ends normally without an explicit COMMIT, an implicit COMMIT is issued to make the
modifications performed by the transaction permanent.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 115
Oracle 10g Database Associate Lesson 4 Database Interfaces
An alternative form of this statement, CREATE TABLE AS SELECT ... (CTAS) can be used to
duplicate an existing table structure and content. A WHERE clause can be used with this form of the
SELECT statement to limit the rows added into the new table.
The ALTER statement can be used to add, modify or remove the structure of one or more columns in
an existing table. Restrictions are in place to avoid the opportunity for data loss by executing this
statement.
The DROP statement can be used to unconditionally remove a table content and structure.
V2: Page 116 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
SQL*Plus Commands
ODBA10gDB-OCA--04-21 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
SQL*Plus Commands
For all versions of SQL*Plus, management commands can be used to customise the presentation and
environment in which commands are run.
Examples illustrated include changing the display format of a column (the COLUMN command) and
customising the environment for the current session (the SET command).
The SHOW command is used to display the current setting for a SQL*Plus environment variable.
The SHOW ALL command can be used to list all modifiable values, together with their current setting.
Unlike SQL commands, the SQL*Plus command keywords can be abbreviated. For example, a
COLUMN command can be used as the keyword COL.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 117
Oracle 10g Database Associate Lesson 4 Database Interfaces
SQL Functions
ODBA10gDB-OCA--04-22 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
SQL Functions
Oracle provides a wide range of built-in functions that can be used to alter data presentation, convert
between data types and provide access to system level features. For a full list of functions, please
refer to the Oracle SQL Language Reference Manual (Part Number B14200-02).
Examples include:
initcap(character_field) initcap(ename)
V2: Page 118 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
SQL*Plus Conventions
ODBA10gDB-OCA--04-23 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
SQL*Plus Conventions
SQL statements are multi-line and must be terminated with a semi-colon (or a single / in column 1).
The most recent statement is saved in an internal buffer for editing, saving or reuse.
Statements can be edited in either line mode (tricky!) or by typing the EDIT command to invoke a
full screen editor. Saved files are automatically retrieved into the SQL*Plus buffer after editing.
The SAVE and GET commands can be used to write and reload commands to and from disk.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 119
Oracle 10g Database Associate Lesson 4 Database Interfaces
Procedural Language
ODBA10gDB-OCA--04-24 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
PL/SQL
The PL/SQL language is an Oracle proprietary extension to SQL, used to provide batch processing
and stored code capabilities.
PL/SQL blocks can be created as "anonymous blocks", entered and executed through any of the
interactive SQL tools.
DECLARE
v_balance NUMBER(10,2);
BEGIN
SELECT amount_due INTO v_balance
FROM customer WHERE id = 20;
A PL/SQL block can contain a mix of procedural statements to control loops and make decisions,
together with SQL statements for database access.
V2: Page 120 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
Stored Code
SQLPLUS>
SQLPLUS> execute
execute update_all;
update_all;
Executed
SQLPLUS>
SQLPLUS> execute
execute update_all;
update_all;
SGA
ODBA10gDB-OCA--04-25 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Stored Code
Code can be stored within the database, as procedures, functions, packages (groupings of procedures
and functions) or triggers (automatically executed code routines invoked in response to a table or
database event).
A CREATE [ PROCEDURE | FUNCTION | PACKAGE | TRIGGER ] command is used to store and
compile the code.
For all stored code, except the automatically invoked triggers, execution can be requested by using the
EXECUTE command as below. User-defined functions can be used in the same way as system
provided functions discussed previously.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 121
Oracle 10g Database Associate Lesson 4 Database Interfaces
Enterprise Manager
ODBA10gDB-OCA--04-26 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Enterprise Manager
The graphical Enterprise Manager(EM) tool is the main feature of Oracle 10g for DBA tasks to
manage databases.
EM runs inside a browser and is invoked at the browser location displayed after creating the database.
The default location (for the database control) is :
http://<hostname>:1158/em
A DBCONSOLE service or daemon must be running against the database before EM can be used.
In order to connect to the database, a suitable login and password must be supplied. For executing
privileged DBA commands, a SYSDBA or SYSOPER account must be specified.
V2: Page 122 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
EM Home Page
ODBA10gDB-OCA--04-27 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
EM Home Page
The EM Home Page provides a summary of the selected database status.
Information provided includes the following categories:
General Database status, version, host informationm listener status
Host CPU Load status, paging statistics
Active Session Wait status, user I/O and CPU statistics for Oracle processes
SQL Statistics If statistics are available, shows SQL details (Lesson 19)
Diagnostic Info Automated Database Diagnostic Monitor (ADDM) information
Disk Space Summary Database sizing information and problem information
High Availability Info Statistics for automated failure recovery
Alerts Critical and warning alert information for DBA attention
Job Overview Information on scheduled jobs
Related Links Links to additional pages containing more DBA statistics
The majority of graphical displays and textual information are live links, that can be clicked to drill
down for further information.
Most pages refresh automatically, according to the refresh schedule at the top right of the page.
Details are discussed throughout this class in relevant lessons.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 123
Oracle 10g Database Associate Lesson 4 Database Interfaces
EM Performance
ODBA10gDB-OCA--04-28 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
EM Performance
The EM Performance page shows the following statistics for the past hour
Host CPU Utilisation percentage
Average active sessions Wait statistics that may indicated potential database slowdowns
Instance Disk I/O Database read/write request rates
Instance Throughput Indicates potential contention issues in the database.,
V2: Page 124 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
EM Administration
ODBA10gDB-OCA--04-29 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
EM Administration
The EM Administration page allows sundry management tasks to be carried out, including
Database Administration
Storage File and tablespace management
Database Configuration Initialisation file management
Database Scheduler Jobs, schedules, programs and windows
Statistics Management AWR and optimiser statistics
Change Database Automatic Storage Management and tablespace migration
Schema Administration
Database Objects Management for tables, indexes, view & other schema objects
Programs Management for stored PL/SQL and Java code objects
Users and Privileges Users, roles and privilege management
Materialized Views Materialized view management and diagnostics
EM Administration
Administrators Define privileged EM administrators
Notification Schedule Manage automatic notification schedules
Blackouts Suspend database monitoring for database maintenance ops.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 125
Oracle 10g Database Associate Lesson 4 Database Interfaces
EM Maintenance
ODBA10gDB-OCA--04-30 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
EM Maintenance
The EM Maintenance page provides access to functions affecting the entire Oracle database.
High Availability
Backup/Recovery Schedule and perform backup and recovery operations
Data Movement
Move Row Data Export, import and data load operations
Move Database Files Duplicate (clone) database; transport files to other database
Software Deployment
Installed Software Check for all installed Oracle products
V2: Page 126 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 4 Database Interfaces Oracle 10g Database Associate
Summary
ODBA10gDB-OCA--04-31 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 127
Oracle 10g Database Associate Lesson 4 Database Interfaces
Practice 4
ODBA10gDB-OCA--04-32 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Practice 4
In this practice, you will utilise several of the supplied SQL interfaces.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
V2: Page 128 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
5
0
Starting and Stopping Oracle
ODBA10gDB-OCA-05-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 129
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
Objectives
ODBA10gDB-OCA-05-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
This lesson examines the commands and processes required to start up and shutdown an Oracle
database instance, including:
Enterprise Manager Database Control
The Oracle instance
The iSQL*Plus background process
Additional topics explored include the use of parameter files for instance tuning and alert logs for
monitoring significant database events.
V2: Page 130 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
EM Database Control
ODBA10gDB-OCA-05-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
EM Database Control
The EM Database Control, introduced in Lesson 4, can be used for most database administration
tasks. The interface is displayed in a browser as already demonstrated.
Before the EM can be displayed, the dbconsole process (for UNIX) or service (for Windows) must
be started. The process is automatically created and started up during database creation.
Alternatively, the SQL*Plus interface can be used to start and stop the instance. No pre-started
program is required to administer the database if SQL*Plus is used.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 131
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
ODBA10gDB-OCA-05-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Use the following command (in a UNIX/Linux shell or Windows cmd session):
To start the dbconsole process after a system reboot, ensure that the ORACLE_HOME/bin directory is
on your path, then issue the command:
In Windows, the process can also be started as a service. Click Start, Control Panel, Administrative
Tools, Services to display the services page.
Scroll down to the entry labelled OracleDBConsole<SID>, where <SID> is the database system
identifier. Right click the process and select Start from the context menu.
The dbconsole service maintains log files in:
<Oracle_Home>/<host>_<SID>/sysman/log
V2: Page 132 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
The emctl command can also be used for other purposes. See the help screen below:
OS>emctl
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
Invalid arguments
EM Agent
Part of the function of the EM database control is delegated to a separate agent process. The agent
logs in to the database and passes control information to the EM database control for graphical
presentation of performance and status.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 133
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
Starting a Listener
ODBA10gDB-OCA-05-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Starting a Listener
A listener process is required to provide a connection mechanism between client processes and the
database server. The listener performs the following tasks:
To start a listener following a system restart, use the Listener Control utility as below:
V2: Page 134 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
ODBA10gDB-OCA-05-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
For Microsoft Windows only, an additional service must be started to be able to use the database.
The instance runs all server processes as threads within a single OS process.
To start the process, click Start, Control Panel, Administrative Tools, Services to display the services
page.
Scroll down to the entry labelled OracleService<SID>, where <SID> is the database system
identifier. Right click the process and select Start from the context menu.
Alternatively, open a command window and enter the command below to start the service:
The service can also be set to automatically start the associated database instance, using the
Windows control panel.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 135
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
ODBA10gDB-OCA-05-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
The following parameters are required to connect to and start the database:
Host credentials
Username Enter OS account name for Oracle owner e.g. oracle or
administrator
Password Enter OS account password for the selected host username
Save as Preferred Credential Check to save this information for future logins (applies to
both host and target credentials).
V2: Page 136 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
Status Screen
ODBA10gDB-OCA-05-8 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Status Screen
The listener status and agent status is also reported by this screen.
To start the database, click the Startup button at the top right hand corner of the screen.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 137
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
Startup/Shutdown Confirmation
ODBA10gDB-OCA-05-9 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Startup/Shutdown Confirmation
After clicking the startup button on the status screen, a confirmation screen is displayed.
The Show SQL button can be used to display the SQL command that will be issued by EM to
perform the operation. Many other EM screens also include the same button.
SQL commands can also be issued via SQL*Plus to perform the same operation this applies
throughout the EM product.
V2: Page 138 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
Startup Progress
ODBA10gDB-OCA-05-10 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Startup Progress
A startup progress screen will be displayed whilst the database instance is started.
The database instance will transition through the following stages during startup:
Stage Actions
NOMOUNT Parameter file is opened from default (or other) location
SGA is initialised according to parameter specifications
Background processes are initialised
MOUNT Parameter file CONTROL_FILES entry is used to locate and open all
control files
OPEN Data files are located from V$DATAFILES dictionary table.
Status (SCN) is checked between control file and datafile header
If all files agree, database is opened for normal use
If files are out of sync, database recovery may be required (see later
lessons)
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 139
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
Shutdown Options
ODBA10gDB-OCA-05-11 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Shutdown Options
Under normal circumstances, a started database instance can (and should) be left running 24/7.
Unattended jobs can be scheduled to execute in off-peak periods. Oracle is installed with several
automatic jobs that will not be run if the instance is down.
Maintenance operations, including backups of selected
tablespaces and datafiles, can also be performed
automatically without requiring a database shutdown.
If the database instance does need to be shut down, for
maintenance on the hardware, the EM Home, General
Tab can be used to initiate the operation.
Clicking the Shutdown button displays a shutdown
confirmation screen.
On this screen, the Advanced Options button
displays a further list of shutdown modes that can be
used. A Browse Sessions button can also be used to
display a full list of currently connected processes. These include both user processes and
background daemon processes.
The following shutdown options can be selected from the advanced screen.
Mode Usage
Normal Waits for all users to disconnect before shutting down
Transactional Waits for user to commit (or rollback) before disconnecting the session
Immediate Disconnects users, rolling back work in progress, then shuts down
Abort Shuts down immediately, without writing pending work to disk.
V2: Page 140 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
Starting iSQL*Plus
ODBA10gDB-OCA-05-12 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Starting iSQL*Plus
For open databases, an isqlplus application server process is required in order to accept
connection requests.
To start the application server process, use the following command from an OS shell:
isqplusctl start
To shutdown the application server processes, use the following command from an OS shell:
isqplusctl stop
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 141
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
Parameter Files
EM>Administration>Database Configuration
>All Initialization Parameters > SPFile tab
Server Parameter File resides at
<OracleHome>/dbs/SPFILE<SID>.ORA
Can be exported to text file using
CREATE PFILE FROM SPFILE
Text PFILE resides at
<OracleHome>/database/init<SID>.ora
ODBA10gDB-OCA-05-13 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Parameter Files
To start an instance, a parameter file is required which is used to store memory configuration and
other tuning parameters. A starter file is generated as a database is created during software
installation or subsequently.
The SPFILE format is preferred, since parameter changes can be made dynamically during instance
running. In some cases, these are made and stored automatically by Oracle.
In contrast, a PFILE is only read during instance startup. Subsequent parameter file changes require
that Oracle is shutdown and restarted in order to recognise the parameter changes.
V2: Page 142 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
*.audit_file_dest='C:\oracle/admin/v10g/adump'
*.background_dump_dest='C:\oracle/admin/v10g/bdump'
*.compatible='10.2.0.1.0'
*.control_files='C:\oracle\oradata\v10g\control01.ctl',...
*.core_dump_dest='C:\oracle/admin/v10g/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='v10g'
*.db_recovery_file_dest='C:\oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=v10gXDB)'
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=96468992
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=289406976
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='C:\oracle/admin/v10g/udump'
ODBA10gDB-OCA-05-14 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Select the Administration tab and select the All Initialization Parameters link.
This screen displays parameters in groups of 50 values the drop down list and Next/Previous links
above the table of parameters allows pagination through the list. The Show All button can be used
to display all parameters.
The Name box and other control at the top left of the screen allow wildcard selection on the
parameter name column, limiting the parameters displayed.
To save the current parameter set to a PFILE format, select the Save to File button. This invokes a
browser file save sequence, during which you can select the name and location of the file to be saved
(depending on the browser in use).
If changes are made to the value of any parameter, check the Apply changes in current running
instance(s) checkbox in order to apply the changes immediately.
If the system running the EM browser is online, the icon can be clicked to display help from the
Oracle TechNet website on the selected parameter.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 143
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
Alert Log
ODBA10gDB-OCA-05-15 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Alert Log
An alert log in text format is maintained automatically by the Oracle server, in the directory identified
by the background_dump_dest parameter.
This file records significant events in the life of the database, including
startup and shutdown operations,
creation, alteration and deletion of disk area
changes to system wide parameters
errors in client and server processes
The log file can be examined using EM. From the main pages, scroll to the Related Links section at
the bottom of the page; select Alert Log Content list.
V2: Page 144 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
ODBA10gDB-OCA-05-16 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 145
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
undo_management = AUTO
undo_tablespace = UNDOTBS1
remote_login_passwordfile= EXCLUSIVE
db_domain =
dispatchers = (PROTOCOL=TCP) (SERVICE=v10gXDB)
job_queue_processes = 10
audit_file_dest = C:\ORACLE\PRODUCT\10.2.0\ADMIN\V10G\ADUMP
background_dump_dest = C:\ORACLE\PRODUCT\10.2.0\ADMIN\V10G\BDUMP
user_dump_dest = C:\ORACLE\PRODUCT\10.2.0\ADMIN\V10G\UDUMP
core_dump_dest = C:\ORACLE\PRODUCT\10.2.0\ADMIN\V10G\CDUMP
db_name = v10g
open_cursors = 300
pga_aggregate_target = 96468992
PSP0 started with pid=3, OS id=576
MMAN started with pid=4, OS id=1276
PMON started with pid=2, OS id=1064
DBW0 started with pid=5, OS id=1432
LGWR started with pid=6, OS id=1440
CKPT started with pid=7, OS id=1420
SMON started with pid=8, OS id=1408
RECO started with pid=9, OS id=1404
CJQ0 started with pid=10, OS id=1396
MMON started with pid=11, OS id=1484
MMNL started with pid=12, OS id=1488
Wed May 09 17:17:57 2007
starting up 1 dispatcher(s) for network address
'(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
starting up 1 shared server(s) ...
Wed May 09 17:18:00 2007
alter database mount exclusive
Wed May 09 17:18:05 2007
Setting recovery target incarnation to 2
Wed May 09 17:18:05 2007
Successful mount of redo thread 1, with mount id 2703632776
Wed May 09 17:18:05 2007
Database mounted in Exclusive Mode
Completed: alter database mount exclusive
Wed May 09 17:18:06 2007
alter database open
Wed May 09 17:18:08 2007
Thread 1 opened at log sequence 5
Current log# 1 seq# 5 mem# 0: C:\ORACLE\PRODUCT\10.2.0\ORADATA\V10G\REDO01.LOG
Successful open of redo thread 1
Wed May 09 17:18:16 2007
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Wed May 09 17:18:16 2007
SMON: enabling cache recovery
Wed May 09 17:18:26 2007
Successfully onlined Undo Tablespace 1.
Wed May 09 17:18:26 2007
SMON: enabling tx recovery
Wed May 09 17:18:27 2007
Database Characterset is WE8MSWIN1252
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
QMNC started with pid=16, OS id=480
Wed May 09 17:19:03 2007
Completed: alter database open
Wed May 09 17:19:13 2007
...
V2: Page 146 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 5 Starting and Stopping Oracle Oracle 10g Database Associate
Summary
ODBA10gDB-OCA-05-17 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 147
Oracle 10g Database Associate Lesson 5 Starting and Stopping Oracle
Practice 5
Practice 5
In this practice, you will shutdown and restart your database.
________________________________________________________________________
Try to connect using any of the available interactive SQL*Plus interfaces make notes of the error
messages displayed
________________________________________________________________________
________________________________________________________________________
Restart the database (Ch05Startup.sql) and confirm that you can connect now via SQL*Plus
________________________________________________________________________
________________________________________________________________________
V2: Page 148 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
6
0
Tablespaces and Datafiles
ODBA10gDB-OCA-06-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 149
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
Objectives
ODBA10gDB-OCA-06-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
Lesson 6 examines the use of tablespaces and datafiles for storing system and user information.
Topics include:
The purpose and use of tablespaces and datafiles
EM and SQL commands for managing tablespaces and datafiles
Data dictionary information held by Oracle
Default and required tablespaces used by Oracle
V2: Page 150 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
Tablespaces
ODBA10gDB-OCA-06-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Tablespaces
All Oracle 10g databases require at least two tablespaces to operate in a practical environment these
are SYSTEM and SYSAUX. Other tablespaces e.g. UNDO and TEMP are strongly recommended and
production systems will typically include many more tablespaces.
A tablespace is the unit to which logical structures (tables, indexes ) are allocated. A tablespace is
composed of one or more operating system files (data files).
Newly created databases built with the DBCA will have several tablespaces (see page 155 and Lesson
2 Typical Disk Structure). A manually created database will require a similar setup.
The tablespace definition may include default storage parameters, that reserve space for objects that
do not override the tablespace storage clause in the object creation statement. These storage criteria
apply only to tablespaces where segment management is manual (see page 169).
Except for critical tablespaces including SYSTEM and UNDO, a tablespace may be taken offline for
repair or moving the files.
A tablespace can be managed by adding data files to increase the space available for contained
objects.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 151
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
Datafiles
ODBA10gDB-OCA-06-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Datafiles
Each tablespace owns one or more datafiles, which can be spread across as many different disks and
disk units as required.
The DBA can manually extend or move a datafile to balance the I/O load on demand.
A datafile includes an AUTOEXTEND property that allows it to grow by a set increment, optionally
until it reaches a maximum size.
V2: Page 152 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
Objects positioned in
one tablespace Database
Multiple data files
Tablespace Data file
belong to tablespace
Segment
Tablespace size is
sum of data files Extent
ODBA10gDB-OCA-06-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
A tablespace consists of one or more data files. Each data file can only belong to a single tablespace.
The tablespace size is the sum of all data files that belong to the tablespace.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 153
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
Tablespace Types
Extent Management
Locally Managed
Dictionary Managed
File Types
Smallfile
Bigfile
Segment Management
Auto
Manual
ODBA10gDB-OCA-06-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Tablespace Types
Extent Management
Locally managed tablespaces (LMTs) are the default and preferred option for Oracle 10g. A locally
managed tablespace reserves some header blocks for a bitmap of the free and used space within a
tablespace. Using locally managed tablespaces offloads a major source of possible contention in the
SYSTEM tablespace.
Dictionary managed tablespaces (DMT) use the DBA_FREE_SPACE view in the SYSTEM tablespace for
managing free space areas. Oracle do not recommend creating dictionary managed tablespaces in
Oracle 10g. This feature is scheduled for future de-support.
More information is discussed shortly.
File Types
A smallfile tablespace is the default Oracle tablespace type, which can contain 1022 datafiles or
tempfiles, each of which can contain up to 222 or 4M blocks.
A bigfile tablespace contains only one datafile (or tempfile). The file can contain up to 232 or 4G
blocks. The maximum size of the single datafile or tempfile is 128 terabytes (TB) for a tablespace
with 32K blocks and 32TB for a tablespace with 8K blocks.
V2: Page 154 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
Installation Tablespaces
ODBA10gDB-OCA-06-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Installation Tablespaces
The following tablespaces are created for new DBCA created databases:
SYSTEM Stores the main data dictionary and a default SYSTEM rollback segment
For more information, see page 156
TEMP Used for overflow information from PGA during SQL operations
For more information, see page 157
EXAMPLE Optional tablespace used for holding example data for databases created from
supplied templates.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 155
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
SYSTEM
Created by CREATE DATABASE command
Contains main data dictionary tables
Contains SYSTEM rollback segment
SYSAUX
Auxiliary storage not required for startup
Automatic Workload Repository
ODBA10gDB-OCA-06-8 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
If the SYSTEM tablespace is locally managed, then all other tablespaces must also be locally managed
i.e. not dictionary managed.
The SYSAUX tablespace is an extension tablespace for the SYSTEM tablespace. Many required and
optional database components use the SYSAUX tablespace as their default location to store data. The
SYSAUX tablespace is therefor always created during database creation or database upgrade.
During normal database operation, the SYSTEM and SYSAUX tablespaces cannot be dropped or renamed.
If the SYSAUX tablespace is unavailable due to a media failure, an instance can still continued to be
used but some database features might not be available or may fail.
V2: Page 156 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
TEMP
ODBA10gDB-OCA-06-9 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
TEMP
Temporary tablespaces store information generated and used during SQL statements, where the space
required exceeds the assigned PGA memory.
The operations that require temporary storage space include sort space for unindexed queries, index
creation statements, grouped queries and more.
For (upgraded) databases with locally managed SYSTEM tablespaces, at least one default temporary
tablespace must be available. A locally managed SYSTEM tablespace cannot be used for default
temporary storage.
A default temporary tablespace for all users can be set using the Database Instance: v10g >
Tablespaces > Edit Tablespace screen; check the Set as default temporary tablespace
checkbox.
Temporary tablespace groups enable the use of temporary space from multiple tablespaces. Using a
tablespace group rather than a single temporary tablespace reduces problems caused when one
tablespace is insufficient to hold the results of a sort.
A temporary tablespace group name can be assigned as a default temporary tablespace for the
database or as a temporary tablespace for an individual user (discussed in a later lesson).
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 157
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
EM & Tablespaces
ODBA10gDB-OCA-06-10 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
EM & Tablespaces
To display the tablespace usage within Enterprise Manager, select Administration > Tablespaces
Each tablespace is listed, with details including the tablespace size, usage (MB and %), free space,
status, datafiles, extent management and segment management.
More information can be displayed by selecting the associated radio button and clicking View. A
variety of actions can be carried out by selecting the required option from the Actions drop-down
list.
V2: Page 158 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
ODBA10gDB-OCA-06-11 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
If these parameters are set, new tablespaces can be created via SQL*Plus using the following
command:
No file name or size is required; the new file is created with an Oracle generated name in the default
location and with a standard size of 100 megabytes.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 159
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
Inside a tablespace
t1 t2 t1 t2 free t2
Empty
Six extents blocks
Different sizes
Free space embedded in extents
Free space can be within tablespace
ODBA10gDB-OCA-06-12 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Inside a tablespace
Space inside a tablespace is assigned to permanent objects as contiguous sets of disk blocks; each set
of blocks is termed an extent.
Depending on the tablespace type, the size of the extent may be Oracle- or user-specified.
Each extent is dedicated to a specified type of object. When information is added to the object, the
assigned space is consumed. Further space can be added to the object automatically. As information
is deleted from the object, the space is retained by the object and subsequently reused when further
information is added.
V2: Page 160 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
Tablespace Management
ALTER TABLESPACE t1
[OFFLINE|ONLINE|READ ONLY|READ WRITE]
DROP TABLESPACE t1
[INCLUDING CONTENTS [AND DATAFILES]
[CASCADE CONSTRAINTS]]
ODBA10gDB-OCA-06-13 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Tablespace Management
The following commands can be used to manage a tablespace via any of the SQL interfaces:
CREATE TABLESPACE
The CREATE TABLESPACE statement builds new tablespaces and adds one or more data-files to the
tablespace.
ALTER TABLESPACE
The ALTER TABLESPACE statement can add or drop datafiles from a tablespace and change the
ONLINE / OFFLINE or READ ONLY / READ WRITE status of the tablespace.
DROP TABLESPACE
The DROP TABLESPACE statement can be used to drop a tablespace (including both contents and
datafiles if required). Note that dropping a tablespace with contents may require a recovery operation
for the entire database in order to restore the information contained in the tablespace.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 161
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
Datafile Management
ALTER DATABASE
DATAFILE 'file_name'
RESIZE size[K|M|G|T];
ALTER DATABASE
RENAME FILE
'old_file_name' TO
'new_file_name';
ODBA10gDB-OCA-06-14 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Datafile Management
Datafiles can be resized manually, in order to provide more space for objects contained in the parent
tablespace.
Oracle also provides an option for each datafile to allow additional space to be added automatically
(auto-increment) until the file reaches a specified size.
Files can be moved to new locations on disk, and the ALTER DATABASE RENAME FILE statement can
then be used to update the Oracle dictionary and control files to recognise the new location. This may
take the contents of the file offline for the duration of the move operation.
File renaming is not possible via Enterprise Manager and therefore must be performed using
command line SQL*Plus.
V2: Page 162 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
DBA_TABLESPACES
V$TABLESPACE
DBA_DATA_FILES
V$DATAFILE
DBA_TEMP_FILES
V$TEMPFILE
ODBA10gDB-OCA-06-15 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Data Dictionary
DBA_TABLESPACES
Name Null? Type
----------------------------------------- -------- ----------------------------
TABLESPACE_NAME NOT NULL VARCHAR2(30)
BLOCK_SIZE NOT NULL NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NOT NULL NUMBER
MAX_EXTENTS NUMBER
PCT_INCREASE NUMBER
MIN_EXTLEN NUMBER
STATUS VARCHAR2(9)
CONTENTS VARCHAR2(9)
LOGGING VARCHAR2(9)
FORCE_LOGGING VARCHAR2(3)
EXTENT_MANAGEMENT VARCHAR2(10)
ALLOCATION_TYPE VARCHAR2(9)
PLUGGED_IN VARCHAR2(3)
SEGMENT_SPACE_MANAGEMENT VARCHAR2(6)
DEF_TAB_COMPRESSION VARCHAR2(8)
RETENTION VARCHAR2(11)
BIGFILE VARCHAR2(3)
V$TABLESPACE
Name Null? Type
----------------------------------------- -------- ----------------------------
TS# NUMBER
NAME VARCHAR2(30)
INCLUDED_IN_DATABASE_BACKUP VARCHAR2(3)
BIGFILE VARCHAR2(3)
FLASHBACK_ON VARCHAR2(3)
ENCRYPT_IN_BACKUP VARCHAR2(3)
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 163
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
DBA_DATA_FILES
Name Null? Type
----------------------------------------- -------- ----------------------------
FILE_NAME VARCHAR2(513)
FILE_ID NUMBER
TABLESPACE_NAME VARCHAR2(30)
BYTES NUMBER
BLOCKS NUMBER
STATUS VARCHAR2(9)
RELATIVE_FNO NUMBER
AUTOEXTENSIBLE VARCHAR2(3)
MAXBYTES NUMBER
MAXBLOCKS NUMBER
INCREMENT_BY NUMBER
USER_BYTES NUMBER
USER_BLOCKS NUMBER
ONLINE_STATUS VARCHAR2(7)
V$DATAFILE
Name Null? Type
----------------------------------------- -------- ----------------------------
FILE# NUMBER
CREATION_CHANGE# NUMBER
CREATION_TIME DATE
TS# NUMBER
RFILE# NUMBER
STATUS VARCHAR2(7)
ENABLED VARCHAR2(10)
CHECKPOINT_CHANGE# NUMBER
CHECKPOINT_TIME DATE
UNRECOVERABLE_CHANGE# NUMBER
UNRECOVERABLE_TIME DATE
LAST_CHANGE# NUMBER
LAST_TIME DATE
OFFLINE_CHANGE# NUMBER
ONLINE_CHANGE# NUMBER
ONLINE_TIME DATE
BYTES NUMBER
BLOCKS NUMBER
CREATE_BYTES NUMBER
BLOCK_SIZE NUMBER
NAME VARCHAR2(513)
PLUGGED_IN NUMBER
BLOCK1_OFFSET NUMBER
AUX_NAME VARCHAR2(513)
FIRST_NONLOGGED_SCN NUMBER
FIRST_NONLOGGED_TIME DATE
V2: Page 164 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
DBA_TEMP_FILES
Name Null? Type
----------------------------------------- -------- ----------------------------
FILE_NAME VARCHAR2(513)
FILE_ID NUMBER
TABLESPACE_NAME NOT NULL VARCHAR2(30)
BYTES NUMBER
BLOCKS NUMBER
STATUS CHAR(9)
RELATIVE_FNO NUMBER
AUTOEXTENSIBLE VARCHAR2(3)
MAXBYTES NUMBER
MAXBLOCKS NUMBER
INCREMENT_BY NUMBER
USER_BYTES NUMBER
USER_BLOCKS NUMBER
V$TEMPFILE
Name Null? Type
----------------------------------------- -------- ----------------------------
FILE# NUMBER
CREATION_CHANGE# NUMBER
CREATION_TIME DATE
TS# NUMBER
RFILE# NUMBER
STATUS VARCHAR2(7)
ENABLED VARCHAR2(10)
BYTES NUMBER
BLOCKS NUMBER
CREATE_BYTES NUMBER
BLOCK_SIZE NUMBER
NAME VARCHAR2(513)
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 165
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
ODBA10gDB-OCA-06-16 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Each extent is a series of contiguous Oracle data blocks allocated to the segment as a unit.
V2: Page 166 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
Segments
ODBA10gDB-OCA-06-17 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Segments
A segment is a set of extents allocated for a single logical structure (table, index and more).
The following table describes the different types of segments.
Segment Type Description
Data Each table has a data segment. All table data is stored in the extents of the
data segment..
Index An index has an index segment that stores all of its data (key values and
ROWID / disk addresses of associated data rows)
Temporary Temporary segments are created by Oracle when a SQL statement needs a
temporary database area to operate. Extents in the temporary segment are
returned to the system for future use when the statement finishes
execution.
Rollback/ If the database is in automatic undo management mode, then the database
Undo server manages undo space using dedicated tablespaces. Oracle
recommends that you use automatic undo management. These segments
are discussed in a separate lesson.
Oracle releases before 10g used rollback segments to store undo
information, for use during database recovery and for rolling back
uncommitted transactions for users.
Oracle 10g still uses a SYSTEM rollback segment for performing system
transactions, which is created automatically at CREATE DATABASE time.
No maintenance or management is required for the SYSTEM rollback
segment.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 167
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
Extents
ODBA10gDB-OCA-06-18 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Extents
An initial extent is assigned when an object is created. Further next extents can be assigned
throughout the lifespan of an object.
Extents can be of different sizes although this can create issues for reuse of the space if an object is
dropped.
Extents are contained within a single data file, although the extents for an object can spread across
several data files belonging to a tablespace.
V2: Page 168 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
ODBA10gDB-OCA-06-19 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Manual
Manual free space management uses a setting for each segment called PCTFREE, which sets a
percentage of free space to be maintained in each block. Once this level has been reached, the
block is no longer used for further inserts. The block is removed from a freelist until sufficient
rows have been deleted from the block to reduce the space usage to a lower level, called
PCTUSED. This manual space free management is less efficient than the alternative.
Automatic
Oracle 10g also supports Automatic Segment Space Management (ASSM). With this mechanism,
a bitmap is held at the beginning of each extent, which records the level of fullness of each block
in a series of bands (< 25%, 25%-50%, 50%-75%, 75%+). When searching for a block to
perform an insert, the DBWR can select a block with an appropriate amount of free space, thus
packing rows more tightly into the segment.
In addition, whereas freelist or manual space management typically has a single chain of free
blocks within a segment, ASSM distributes the free status information for blocks across multiple
header blocks. Because each block in the freelist bitmap can be accessed and updated separately,
the use of ASSM causes less contention for the DBWR. The performance of multiple concurrent
updates to a single segment is therefore dramatically improved.
ASSM is the default space management method for Oracle 10g. Manual space management is
supported only for backwards compatibility for databases that have been upgraded from prior releases
of Oracle.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 169
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
Extent Allocation
ODBA10gDB-OCA-06-20 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Extent Allocation
For locally managed tablespaces, two extent allocation strategies are provided. The required strategy
can be specified as below:
UNIFORM
The required extent size is specified when the tablespace is first created. Multiple extents are
allocated if a larger storage area is required on object creation.
Uniform space allocation is recommended for use with tablespaces containing many small objects, as
well as for UNDO tablespaces.
AUTOALLOCATE
Oracle assigns extents automatically, using an algorithm developed by Oracle engineers. This
mechanism cannot be overridden for individual tablespaces.
Initially, 8 block / 64K extents are assigned. When sixteen extents have been assigned (i.e. the object
reaches 1 MB in size, the extent size allocated grows to 128 blocks / 1MB. When a further 64 of
these extents have been allocated, the extent size allocated grows again to 1024 blocks / 8MB.
In essence, objects will grow at an exponential rate. This recommended mechanism reduces the load
on the DBA when planning disk usage, by removing the need to micro-manage disk space.
V2: Page 170 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
Blocks
ODBA10gDB-OCA-06-21 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Blocks
A default block size is set for the entire database on creation, and can range from 2k to 32k (or 64k on
some OS versions). A standard block size of 8k is used for all databases created from the supplied
DBCA templates.
If the appropriate system parameters are set up to provide multiple buffer caches, additional
tablespaces can be created with different block sizes for special purposes.
Multiple rows and index entries can be contained within a block conversely, a data row can spread
across multiple blocks (chaining).
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 171
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
DBA_SEGMENTS
DBA_EXTENTS
ODBA10gDB-OCA-06-22 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Data Dictionary
DBA_SEGMENTS
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
SEGMENT_NAME VARCHAR2(81)
PARTITION_NAME VARCHAR2(30)
SEGMENT_TYPE VARCHAR2(18)
TABLESPACE_NAME VARCHAR2(30)
HEADER_FILE NUMBER
HEADER_BLOCK NUMBER
BYTES NUMBER
BLOCKS NUMBER
EXTENTS NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NUMBER
MAX_EXTENTS NUMBER
PCT_INCREASE NUMBER
FREELISTS NUMBER
FREELIST_GROUPS NUMBER
RELATIVE_FNO NUMBER
BUFFER_POOL VARCHAR2(7)
V2: Page 172 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
DBA_EXTENTS
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
SEGMENT_NAME VARCHAR2(81)
PARTITION_NAME VARCHAR2(30)
SEGMENT_TYPE VARCHAR2(18)
TABLESPACE_NAME VARCHAR2(30)
EXTENT_ID NUMBER
FILE_ID NUMBER
BLOCK_ID NUMBER
BYTES NUMBER
BLOCKS NUMBER
RELATIVE_FNO NUMBER
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 173
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
Summary
ODBA10gDB-OCA-06-23 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
V2: Page 174 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 6 Tablespaces and Datafiles Oracle 10g Database Associate
Practice 6
ODBA10gDB-OCA-06-24 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Practice 6
In this practice, you will work with tablespaces.
Using Enterprise Manager, add a second file to the TEST tablespace (Ch06AddDatafile.sql).
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 175
Oracle 10g Database Associate Lesson 6 Tablespaces and Datafiles
Take the tablespace offline and move the datafiles to a new disk location (use a TEMP area on your
disk either C:\Temp for Windows or /tmp for Linux/Unix) (Ch06
V2: Page 176 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
7
0
Schema Objects
ODBA10gDB-OCA-07-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 177
Oracle 10g Database Associate Lesson 7 Schema Objects
Objectives
ODBA10gDB-OCA-07-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
Lesson 7 discusses and demonstrates sundry schema objects, including tables, indexes, constraints,
views and sequences. Topics include:
Creating and modifying tables
Understanding available data types
Defining constraints (business rules)
Viewing the attributes and contents of tables
Creating indexes and views on tables
Creating and using sequences
V2: Page 178 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Schema
ODBA10gDB-OCA-07-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Schema
A database schema is a collection of objects, owned by a named user and sharing the name of the
user account. On logging in to Oracle with an account/user name, the objects owned by the schema
name used to connect are automatically available to the session. Other objects may be accessible,
depending on explicit permissions that may have been granted to the account concerned.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 179
Oracle 10g Database Associate Lesson 7 Schema Objects
Tables
ODBA10gDB-OCA-07-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Tables
A database table is the basic storage structure, consisting of rows (records) and columns (fields) in a
named object. Simple relational tables (also known as heap tables), are used to stored unordered
rows in the order in which the rows were added to the table.
Each table will have one or more columns, with a datatype and an optional size.
To create a new (or alter an existing) table, select the EM Administration page. Click the Schema >
Database Objects > Table link. Enter the name of the schema to be used (or select the searchlight
icon ) to select from a list of available schemas.
Press the GO button to display the tables within the specified schema.
V2: Page 180 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Table Operations
ODBA10gDB-OCA-07-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Table Operations
To operate on an existing table, refer to the displayed list of tables in the selected schema. Select the
radio button corresponding to the object to be operated on and choose an operation from the drop
down action list.
When creating new objects, the currently logged in schema is the default owner of any new objects.
Object Names
All Oracle schema objects must adhere to the following naming rules
Names must begin with an alphabetic character or underscore
Remaining characters can be alphanumeric, underscore, dollar or hash (#) symbols
Maximum length is thirty characters
Name selected must be unique within the namespace (schema)
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 181
Oracle 10g Database Associate Lesson 7 Schema Objects
ODBA10gDB-OCA-07-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Enter details of the columns to be created. For each column, specify a name and a data type.
V2: Page 182 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 183
Oracle 10g Database Associate Lesson 7 Schema Objects
ODBA10gDB-OCA-07-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
V2: Page 184 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Tablespace
logging parameters
Extents
initial size
Space Usage
percentage free/used
Free Lists
for dictionary tablespaces
Transactions
reserved space requirements
Buffer Pool
keep, recycle, default
ODBA10gDB-OCA-07-8 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Extent Parameters
Overrides the storage clause, initial extent size for the (dictionary managed) tablespaces.
Space Usage
Sets the spare space to be left in each block for growth to existing rows in blocks (see page 190). This
applies for objects in tablespaces with SEGMENT SPACE MANAGEMENT MANUAL only.
Transactions Parameters
Sets the number of concurrent updates that can be applied to a single block. Leave as default unless
using multi-cpu systems.
Buffer Pool
Select one of KEEP, RECYCLE or DEFAULT to assign blocks in the buffer cache to an appropriate
sub-pool. Requires appropriate memory configuration (discussed later).
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 185
Oracle 10g Database Associate Lesson 7 Schema Objects
Row Movement
allows silent optimisation of row placement
Parallelism
permits multiple processes for large tables
Cache
positions rows in optimum SGA buffer on scan
ODBA10gDB-OCA-07-9 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Row Movement
Determines whether Oracle can reposition rows, changing the inherent disk address (rowid). This
may occur during table compression of regular (heap) tables (discussed in Lesson 19) and in other
operations on partitioned tables (not discussed in this course).
Parallelism
Determines whether table creation, queries and subsequent DML operations can be parallelised. Only
appropriate for multi-cpu systems. Values include PARALLEL, NOPARALLEL and PARALLEL n.
Cache
The inclusion of this keyword ensures that retrieved rows are placed at the most recently used end of
the buffer list within the SGA buffer cache on a full table scan. If the (default) NOCACHE clause is
specified, rows retrieved during a full table scan are usually placed at the least recently used end of
the buffer cache list.
V2: Page 186 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
ODBA10gDB-OCA-07-10 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 187
Oracle 10g Database Associate Lesson 7 Schema Objects
Table Storage
PCTFREE n
PCTUSED n Header
STORAGE ( Spare
INITIAL nk
NEXT nK
MINEXTENTS n
Data rows
MAXEXTENTS n
PCTINCREASE n
)
ODBA10gDB-OCA-07-11 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Table Storage
For dictionary managed tablespaces, the following options can be specified:
PCTFREE Percentage of space to leave free fill each block up to 100 PCTFREE
V2: Page 188 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Managing Tables
ALTER TABLE t
Table storage and column structure can be
altered in place
DROP TABLE t [PURGE]
Dropped tables are placed into a
RECYCLEBIN, unless PURGE is specified
MOVE
ALTER can move table to new tablespace
ODBA10gDB-OCA-07-12 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Managing Tables
Some sample statements are illustrated below:
ALTER TABLE
ALTER TABLE t STORAGE (storage-clause);
DROP TABLE
DROP TABLE t;
MOVE TABLE
ALTER TABLE t MOVE TABLESPACE t;
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 189
Oracle 10g Database Associate Lesson 7 Schema Objects
ODBA10gDB-OCA-07-13 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Header holds control and locking information for rows in the block
Spare reserved space, controlled by the tables PCTFREE clause (for tablespaces
specified with SEGMENT SPACE MANAGEMENT MANUAL). The reserved
space is maintained for updates to existing rows in the block.
Data rows the table data, split into row pieces, that are reassembled into a complete
row for query purposes and returned to the requesting user process.
V2: Page 190 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Indexes
ODBA10gDB-OCA-07-14 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Indexes
For any column or combination of columns in a table, a corresponding index structure can be defined
to hold the indexed column values for fast searching and sorting. When a suitable index exists, the
Oracle optimiser will use the index to devise the execution plan for the query.
Indexes require additional disk space and processing for updates; the additional cost of maintaining
the index may be offset by the improved response times on queries.
Indexes can be categorised as below:
Logical Single Column Index declared on a single column.
Multiple Composite index declared on multiple columns;
Column Leading edge of the index must be specified in a query
Unique The index does not allow multiple identical values (primary key)
Duplicate The index permits multiple identical values
Physical Non-partitioned Normal index, contained in a single tablespace
Partitioned Split index; can reside across multiple tablespaces
B-tree Normal / Index is held in forward order (for exact match and
Reverse range searches) or reverse order (for exact match
searches only).
Bitmap Index type that favours data warehousing style queries on large
amounts of data with a limited range of data values (low
cardinality).
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 191
Oracle 10g Database Associate Lesson 7 Schema Objects
Index Storage
PCTFREE n
PCTUSED n Header
STORAGE ( Spare
INITIAL nk
NEXT nK
MINEXTENTS n
Index
MAXEXTENTS n
PCTINCREASE n entries
)
ODBA10gDB-OCA-07-15 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Index Storage
PCTFREE indicates the percentage block space to be reserved for newly inserted rows within the
current range of keys in the block. A table where inserts are performed in key sequence can use a
low PCTFREE value. Where keys are inserted out of sequence, efficiency may be improved by
specifying a higher PCTFREE value.
V2: Page 192 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Managing Indexes
CREATE
ALTER
REBUILD
MOVE
DROP
ODBA10gDB-OCA-07-16 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Managing Indexes
Some sample statements are illustrated below:
Create Index
CREATE INDEX i ON t(c);
Alter Index
ALTER INDEX i_empno PCTFREE 20;
Drop Index
DROP INDEX i_ename;
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 193
Oracle 10g Database Associate Lesson 7 Schema Objects
Views
Views
Database views are stored SQL statements that can be used in queries (and in restricted DML
statements) in place of base tables.
View Name Standard Oracle naming rules apply (as already discussed)
Replace if Exists If checked, create view unconditionally. If not checked, and view
exists, reports an error
Options With Check For updateable views, create associated constraint to prevent DML
operations removing rows from the view
V2: Page 194 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Sequences
Sequences
A database sequence is an independent object used to generate integer numbers in sequence to be used
as primary keys for tables.
Sequences are immune to transaction rollback operations, therefore once a sequence number has been
reserved, the same number will not be reused unless the sequence recycles back to the start.
Sequence numbers can also be cached in memory for speed; however, if the instance aborts, cached
sequence numbers will be lost.
Sequence creation arguments include:
Maximum Must be greater than initial and minimum values
Minimum Must be less than or equal to initial value and less than maximum value
Interval Specifies the Increment By value; negative values generate reversing values
Initial Specifies the Start With value
Cycle Boolean setting to indicate whether the sequence cycles back after reaching the
maximum value
Order Boolean value to ensure that sequence numbers are generated in order of request; only
applicable for Real Application Cluster (RAC) systems
Cache Specifies count of sequences to cache in memory
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 195
Oracle 10g Database Associate Lesson 7 Schema Objects
Using Sequences
ODBA10gDB-OCA-07-19 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Using Sequences
A created sequence has two properties that can be referenced, either in SQL statements or inside
PL/SQL code blocks.
The NEXTVAL property retrieves a new sequence number and automatically advances the sequence
counter to the next available value.
The CURRVAL property retrieves the previous value (within the same transaction) to allow reuse of
the same value for different tables.
V2: Page 196 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Data Dictionary
DBA_TABLES
DBA_TAB_COLUMNS
DBA_INDEXES
DBA_IND_COLUMNS
DBA_VIEWS
DBA_SEQUENCES
ODBA10gDB-OCA-07-20 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Data Dictionary
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 197
Oracle 10g Database Associate Lesson 7 Schema Objects
DBA_TABLES
V2: Page 198 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
DBA_TAB_COLUMNS
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 199
Oracle 10g Database Associate Lesson 7 Schema Objects
DBA_INDEXES
Name Null? Type
----------------------------------------- -------- ----------------------------
V2: Page 200 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
DBA_IND_COLUMNS
DBA_VIEWS
DBA_SEQUENCES
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 201
Oracle 10g Database Associate Lesson 7 Schema Objects
Summary
ODBA10gDB-OCA-07-21 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
V2: Page 202 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 7 Schema Objects Oracle 10g Database Associate
Practice 7
Practice 7
In this practice, you will work with tables, indexes, sequences and views.
Use EM to create a copy of the SCOTT.EMP table in the SYSTEM schema, called NEWEMP.
(Ch07CreateNewEmp.sql)
________________________________________________________________________
________________________________________________________________________
Copy the data into the new table, using the following SQL command: (Ch07CopyEmpData.sql)
INSERT INTO NEWEMP SELECT * FROM SCOTT.EMP
________________________________________________________________________
________________________________________________________________________
After loading the new table, create a new duplicate index on the new tables ENAME column.
(Ch07CreateIndex.sql)
________________________________________________________________________
________________________________________________________________________
Create a new sequence called EMPSEQ in the SYSTEM schema specify the start value as 100
(Ch07CreateSequence.sql).
________________________________________________________________________
________________________________________________________________________
Insert three new rows into the NEWEMP table, using the sequence as the primary key
(Ch07InsertEmployees.sql).
________________________________________________________________________
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 203
Oracle 10g Database Associate Lesson 7 Schema Objects
________________________________________________________________________
Create a new view, EMPMGR, using the clause WHERE JOB = 'MANAGER'
(Ch07CreateView.sql)
________________________________________________________________________
________________________________________________________________________
V2: Page 204 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
8
0
Undo Management
ODBA10gDB-OCA-08-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 205
Oracle 10g Database Associate Lesson 8 Undo Management
Objectives
ODBA10gDB-OCA-08-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
Lesson 8 describes the usage, configuration and administration of undo areas. Topics include:
Understanding the purpose of Undo space
Create, monitor and configure Undo space
Use the Undo Advisor for automated advice
Understand the use of undo space by transactions
Size an undo tablespace appropriately
Know how to set guaranteed retention periods and understand the implications
V2: Page 206 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
Undo Basics
ODBA10gDB-OCA-08-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Undo Basics
Oracle has a mechanism for storing sufficient information to be able to reverse the effect of a
transaction. Information is written to a reserved area (the Undo tablespace) by update statements.
Pre-10g versions of Oracle called this facility ROLLBACK. Oracle 10g still uses a single rollback
segment in the SYSTEM tablespace for selected system operations.
Every database should have a dedicated Undo tablespace for normal user transactional updates.
Once an Undo tablespace has been created and sized correctly, management can be automatic unless a
major change to the system configuration or application load occurs.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 207
Oracle 10g Database Associate Lesson 8 Undo Management
ODBA10gDB-OCA-08-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
When a new database is created during installation or subsequently using the DBCA, an Undo
tablespace is automatically created.
New undo tablespaces can be created as required, to distribute I/O loads across multiple disk units.
On instance startup, if multiple undo tablespaces are found, the first available undo tablespace is
selected for activation. If no undo tablespaces are located, undo information is written to the
SYSTEM tablespace; this is not recommended for long-term production use.
V2: Page 208 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
The CREATE UNDO TABLESPACE command can be used to build additional tablespaces manually
(Ch08CreateUndoSpace.sql).
Datafiles for undo tablespaces must use local for extent management and auto[allocate]
for segment space management. These defaults allows Oracle to create, manage and optimise undo
segments automatically within the undo tablespace, without further DBA intervention.
To prevent running out of disk space for undo information, Oracle recommend that the
autoextend property is specified for all datafiles belonging to undo tablespaces.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 209
Oracle 10g Database Associate Lesson 8 Undo Management
ODBA10gDB-OCA-08-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
To create an undo tablespace using Enterprise Manager, select Administration > Tablespaces. From
the list of tablespaces, select the Create button.
Select the type of the new tablespace as UNDO. Leave Extent Management as Locally
Managed and Status as Read Write.
Click the Add button to specify a datafile name, location and size.
V2: Page 210 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
ODBA10gDB-OCA-08-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 211
Oracle 10g Database Associate Lesson 8 Undo Management
ODBA10gDB-OCA-08-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
During undo tablespace creation, these parameters can be displayed after file names are added to the
creation command.
For existing undo tablespaces, these parameters can be displayed by selecting the Storage tab in the
Create Tablespace screen.
The parameters displayed are for information only and should not generally be changed by the DBA.
V2: Page 212 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
ODBA10gDB-OCA-08-8 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
The UNDO_TABLESPACE dynamic parameter can be changed at any time to use another available undo
tablespace. The old tablespace can be dropped, once any active space within the tablespace has been
released by all potential transactions that may require the information.
The UNDO_RETENTION = seconds parameter is also not required for most databases. Oracle will
automatically tune the use of undo to achieve the maximum possible undo retention period within the
bounds of assigned and available disk space.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 213
Oracle 10g Database Associate Lesson 8 Undo Management
ODBA10gDB-OCA-08-9 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
To activate a different undo tablespace using Enterprise Manager, select Administration > Database
Configuration > Undo Management.
V2: Page 214 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
ODBA10gDB-OCA-08-10 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Active Space containing information that is still required by active transactions for future read
consistency.
Expired Space containing information for completed transactions that may still be required for
future flashback operations.
Unused Space that can be released from the undo tablespace datafiles if the file is resized to be
smaller than at present (wasted space!).
A minimum sized undo tablespace will only retain active space and can reuse expired space as
required. Assigning more space gives more likelihood that other, unrelated transactions will succeed
and not report Snapshot too old errors.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 215
Oracle 10g Database Associate Lesson 8 Undo Management
ODBA10gDB-OCA-08-11 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Query time in minutes, together with average and maximum undo generation rates (KB/minute) are
shown automatically.
The Show Graph link on this page shows three additional graphs,
illustrating the following information for the monitored period. This
value can be changed with the Analysis Time Period drop down list:
Undo tablespace usage green areas indicate possible oversized undo tablespaces
Undo retention auto tuning shows longest running query and maximum flashback duration
Undo generation rate in KB/second
V2: Page 216 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
Manual Sizing
ODBA10gDB-OCA-08-12 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Manual Sizing
For manually sizing undo space, measurements should be taken at peak periods.
If insufficient space is available i.e. the undo tablespace is sized too small, other transactions may fail
with intermittent Snapshot too old errors.
The dynamic performance table V$UNDOSTAT holds statistics gathered every 10 minutes to show the
undo block consumption and any transactions failing because of undo space unavailability
(Ch08UndoStats.sql):
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 217
Oracle 10g Database Associate Lesson 8 Undo Management
ODBA10gDB-OCA-08-13 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
From the Undo Management page, the Undo Advisor button invokes an automated advisor showing
statistics that calculate a recommended size for the undo tablespace based on the recent transaction
load. If the undo_retention parameter is set (see page 213), the guaranteed retention period
is also taken into account in the calculation.
V2: Page 218 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
Use Undo
Advisor graph
Click point on
graph
New size &
period will be
computed
ODBA10gDB-OCA-08-14 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
The graph below the advisor statistics shows the maximum undo retention period plotted against the
amount of disk space required.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 219
Oracle 10g Database Associate Lesson 8 Undo Management
ODBA10gDB-OCA-08-15 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
For more control, an undo tablespace can have a RETENTION GUARANTEE set. Use the following SQL
commands to set this value (Ch08RetentionGuarantee.sql):
Setting this value ensure that the minimum undo_retention period is used to retain undo information
for at least this length of time (in seconds), even if inactive but unexpired data space is required by
other transactions. This may mean that some transactions may fail due to a lack of space in the undo
tablespace.
The retention guarantee can be cleared for a tablespace with the following command:
If retention guarantee is disabled, Oracle may overwrite unexpired undo when space is low. This
reduces the effective undo retention period for the database. Some queries may therefore fail with a
Snapshot too old error message. This option is disabled by default in new databases.
V2: Page 220 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
Summary
ODBA10gDB-OCA-08-16 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 221
Oracle 10g Database Associate Lesson 8 Undo Management
Practice 8
Practice 8
In this practice, you will configure and manage undo tablespaces
Use EM to examine the undo management setup for your database (Ch08UndoInfo.sql).
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Configure a new undo tablespace using Enterprise Manager. Recheck your current setup to ensure
that the new undo tablespace is being used. (Ch08CreateUndoSpace.sql):
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Check the space recommendations from both the EM Undo Advisor and the dynamic performance
table V$UNDOSTAT in the SGA (Ch08UndoInfo.sql).
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
V2: Page 222 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 8 Undo Management Oracle 10g Database Associate
Your instructor will provide you with additional examples of SQL statements to exercise the undo
setup (Ch08Exercise.sql).
________________________________________________________________________
________________________________________________________________________
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 223
Oracle 10g Database Associate Lesson 8 Undo Management
V2: Page 224 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
9
0
Data Administration
ODBA10gDB-OCA-09-1 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 225
Oracle 10g Database Associate Lesson 9 Data Administration
Objectives
ODBA10gDB-OCA-09-2 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Objectives
Lesson 9 describes discusses the SQL commands and external utilities used to move data inside and
across Oracle databases. Topics include:
The SQL INSERT and MERGE statements
The DataPump technology in the database server
The expdp and impdp command line utilities for accessing DataPump
The SQL*Loader utility for importing external files
The use of Oracle directory objects in conjunction with other utilities
V2: Page 226 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
Moving Data
ODBA10gDB-OCA-09-3 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Moving Data
Data rows that have already been loaded into Oracle tables may need to be moved for several reasons.
Within a single database, rows might be moved for technical reasons to another tablespace or
datafile or for business reasons, perhaps to preserve a copy of all or part of a table for further
analysis.
More frequently, data is moved between OLTP and Data Warehousing databases, as part of an ETL
(Extract, Transform, Load) sequence of operations.
There is also the option of loading data into Oracle from external or legacy sources.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 227
Oracle 10g Database Associate Lesson 9 Data Administration
ODBA10gDB-OCA-09-4 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
The SELECT statement can use any required clause that is permitted for this statement
(Ch09InsertSelect.sql).
To insert only certain columns into the target table, the colums must be specified after the tablename
as illustrated below(Ch09InsertPartSelect.sql):
V2: Page 228 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
The INSERT ALL/FIRST statement is used to pivot the rows from a source table into multiple target
tables (Ch09SplitTableQuery.sql).
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 229
Oracle 10g Database Associate Lesson 9 Data Administration
ODBA10gDB-OCA-09-5 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
SQL> CREATE TABLE emp_new AS SELECT * FROM scott.emp WHERE empno <= 7788;
V2: Page 230 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
SERVER
DBMS_DATAPUMP
DBMS_DATAPUMP Data/Metadata
Data/Metadata Engine
Engine
Metadata
Metadata Direct
Direct External
External
API
API Path
Path API
API Table
Table API
API
ODBA10gDB-OCA-09-6 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
DataPump Overview
The DataPump facility is a feature within the database server for transferring data and structural
information (metadata) between databases as well as internally within a single database.
Access to the facility is provided via command line programs for exporting and importing information
from and to an Oracle database.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 231
Oracle 10g Database Associate Lesson 9 Data Administration
expdp
expdp client
client Data Pump Architecture
Source Target
DataPump
DataPump Server
Server
Job
Job Process
Process
Server
Server DataPump
DataPump
Process
Process Job
Job
impdp
impdp client
client
ODBA10gDB-OCA-09-7 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
DataPump export jobs create a Dump File Set in an Oracle directory (see page 238) residing on the
server.
Each DataPump job creates a Master Table in the schema of the user executing the job. This table
controls all aspects of the DataPump job, including the sequence of objects that were exported. The
Master Table is read first during an import and used to sequence the objects being imported. The
table can be used to restarted failed DataPump jobs and is automatically removed once the job has
completed successfully.
The master table is created with a name matching the specified or system-generated job name.
V2: Page 232 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
Master Table
PROCESS_ORDER NUMBER
DUPLICATE NUMBER
DUMP_FILEID NUMBER
DUMP_POSITION NUMBER
DUMP_LENGTH NUMBER
DUMP_ALLOCATION NUMBER
COMPLETED_ROWS NUMBER
ERROR_COUNT NUMBER
ELAPSED_TIME NUMBER
OBJECT_TYPE_PATH VARCHAR2(200)
OBJECT_PATH_SEQNO NUMBER
OBJECT_TYPE VARCHAR2(30)
IN_PROGRESS CHAR(1)
OBJECT_NAME VARCHAR2(500)
OBJECT_LONG_NAME VARCHAR2(4000)
OBJECT_SCHEMA VARCHAR2(30)
ORIGINAL_OBJECT_SCHEMA VARCHAR2(30)
PARTITION_NAME VARCHAR2(30)
SUBPARTITION_NAME VARCHAR2(30)
FLAGS NUMBER
PROPERTY NUMBER
COMPLETION_TIME DATE
OBJECT_TABLESPACE VARCHAR2(30)
SIZE_ESTIMATE NUMBER
OBJECT_ROW NUMBER
PROCESSING_STATE CHAR(1)
PROCESSING_STATUS CHAR(1)
BASE_PROCESS_ORDER NUMBER
BASE_OBJECT_TYPE VARCHAR2(30)
BASE_OBJECT_NAME VARCHAR2(30)
BASE_OBJECT_SCHEMA VARCHAR2(30)
ANCESTOR_PROCESS_ORDER NUMBER
DOMAIN_PROCESS_ORDER NUMBER
PARALLELIZATION NUMBER
UNLOAD_METHOD NUMBER
GRANULES NUMBER
SCN NUMBER
GRANTOR VARCHAR2(30)
XML_CLOB CLOB
NAME VARCHAR2(30)
VALUE_T VARCHAR2(4000)
VALUE_N NUMBER
IS_DEFAULT NUMBER
FILE_TYPE NUMBER
USER_DIRECTORY VARCHAR2(4000)
USER_FILE_NAME VARCHAR2(4000)
FILE_NAME VARCHAR2(4000)
EXTEND_SIZE NUMBER
FILE_MAX_SIZE NUMBER
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 233
Oracle 10g Database Associate Lesson 9 Data Administration
PROCESS_NAME VARCHAR2(30)
LAST_UPDATE DATE
WORK_ITEM VARCHAR2(30)
OBJECT_NUMBER NUMBER
COMPLETED_BYTES NUMBER
TOTAL_BYTES NUMBER
METADATA_IO NUMBER
DATA_IO NUMBER
CUMULATIVE_TIME NUMBER
PACKET_NUMBER NUMBER
OLD_VALUE VARCHAR2(4000)
SEED NUMBER
LAST_FILE NUMBER
USER_NAME VARCHAR2(30)
OPERATION VARCHAR2(30)
JOB_MODE VARCHAR2(30)
CONTROL_QUEUE VARCHAR2(30)
STATUS_QUEUE VARCHAR2(30)
REMOTE_LINK VARCHAR2(4000)
VERSION NUMBER
DB_VERSION VARCHAR2(30)
TIMEZONE VARCHAR2(64)
STATE VARCHAR2(30)
PHASE NUMBER
GUID RAW(16)
START_TIME DATE
BLOCK_SIZE NUMBER
METADATA_BUFFER_SIZE NUMBER
DATA_BUFFER_SIZE NUMBER
DEGREE NUMBER
PLATFORM VARCHAR2(101)
ABORT_STEP NUMBER
INSTANCE VARCHAR2(60)
V2: Page 234 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
ODBA10gDB-OCA-09-8 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Alternatively, the export can be started (and scheduled) using the Enterprise Manager. Select the
Maintenance tab > Data Movement > Export to Export Files links.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 235
Oracle 10g Database Associate Lesson 9 Data Administration
expdp options
C:\Exports>expdp help=y
The Data Pump export utility provides a mechanism for transferring data objects
between Oracle databases. The utility is invoked with the following command:
You can control how Export runs by entering the 'expdp' command followed
by various parameters. To specify parameters, you use keywords:
V2: Page 236 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
Export/Import Modes
Full
entire database (except dictionary)
Schema
one (or more) schemas all objects in schema
Table
one (or more) tables
Tablespace
all objects within one (or more) tablespaces
Transportable Tablespace
metadata for tablespace contents
ODBA10gDB-OCA-09-9 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Export/Import Modes
The following modes are supported by both export and import operations.
Full Copies the entire database contents, except for dictionary information owned by
the SYS schema and other instance specific information.
Schema Copies all objects owned by one or more schemas, including tables, indexes,
views and other objects.
Transportable Creates a dump file containing metadata only for objects residing in one or more
Tablespace tablespaces. The physical datafiles for the named tablespaces can then be
copied to the target server and plugged in to the instance.
To perform a full database export, or to export information owned by other schemas, the
EXP_FULL_DATABASE permission must be granted to the exporting user.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 237
Oracle 10g Database Associate Lesson 9 Data Administration
Directories
CREATE
CREATE DIRECTORY
DIRECTORY exports
exports AS
AS '/home/myExports';
'/home/myExports';
ODBA10gDB-OCA-09-10 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Directories
For data administration features that require access to named files, Oracle requires the creation of a
database DIRECTORY, a named object that is an alias for a physical OS directory.
The DBA must also create the directory in the operating system and ensure that the permissions on the
physical directory match the relevant permissions on the Oracle directory object.
The creating user is granted READ and WRITE privilege on the Oracle directory object
automatically. Other users of the same directory will require specific privilege to be granted
individually.
V2: Page 238 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
Executing an Export
ODBA10gDB-OCA-09-11 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Executing an Export
To execute an export from the command line, use the following command example:
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 239
Oracle 10g Database Associate Lesson 9 Data Administration
Export Output
V2: Page 240 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
Executing an Import
ODBA10gDB-OCA-09-12 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Executing an Import
DataPump imports can be started with the command line impdp utility.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 241
Oracle 10g Database Associate Lesson 9 Data Administration
impdp options
C:\>impdp help=y
The Data Pump Import utility provides a mechanism for transferring data objects
between Oracle databases. The utility is invoked with the following command:
Example: impdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp
You can control how Import runs by entering the 'impdp' command followed
by various parameters. To specify parameters, you use keywords:
V2: Page 242 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
Import Type
ODBA10gDB-OCA-09-13 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Import Type
To begin an import using EM, select Maintenance > Import from Export Files.
This screen requires the selection (or creation) of an Oracle Directory Object and the specification of
the name for the output dump file.
This screen also allows the selection of an Import Type (see page 237).
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 243
Oracle 10g Database Associate Lesson 9 Data Administration
Selected Schemas
ODBA10gDB-OCA-09-14 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Selected Schemas
For a SCHEMA import as selected on the previous slide, the named export file is read to check the
information in the file. The following is displayed during this process:
Once the file has been read, the Add button allows selection of one or more of the schemas found in
the dump file.
V2: Page 244 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
Schema Re-Mapping
ODBA10gDB-OCA-09-15 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Schema Re-Mapping
During the import process, tables can be transferred to other accounts, a process known as schema
remapping
Click the Add Another Row button below the schema list, then select both the source schema to be
remapped and the destination schema to receive the imported objects.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 245
Oracle 10g Database Associate Lesson 9 Data Administration
Import: Options
ODBA10gDB-OCA-09-16 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Options
Step 3 in this process allows specification of a variety of options for the import. Options include:
Number of threads for faster parallel import.
Whether a log file is required, together with a directory and file name if necessary.
V2: Page 246 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
Import: Schedule
ODBA10gDB-OCA-09-17 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Schedule
Step 4 allows entry of an optional job name and schedule information, to provide for later and
unattended execution of the import job.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 247
Oracle 10g Database Associate Lesson 9 Data Administration
Import: Review
ODBA10gDB-OCA-09-18 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Review
Before executing the import, the Review screen displays a summary of the job and options.
The Show PL/SQL button can be used to display the PL/SQL commands that will be used to invoke
the job via the DBMS_DATAPUMP package as illustrated on the next page.
V2: Page 248 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
DBMS_DATAPUMP Job
declare
h1 NUMBER;
begin
begin
h1 := dbms_datapump.open (operation => 'IMPORT', job_mode => 'SCHEMA',
job_name => 'IMPORT000161', version => 'COMPATIBLE');
end;
begin
dbms_datapump.set_parallel(handle => h1, degree => 1);
end;
begin
dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 0);
end;
begin
dbms_datapump.add_file(handle => h1, filename => 'EXPORT.DMP',
directory => 'EXPORTS', filetype => 1);
end;
begin
dbms_datapump.metadata_remap(handle => h1, name => 'REMAP_SCHEMA',
old_value => 'SCOTT', value => 'ANONYMOUS');
end;
begin
dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR',
value => 'IN(''SCOTT'')');
end;
begin
dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD',
value => 'AUTOMATIC');
end;
begin
dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA',
value => 1);
end;
begin
dbms_datapump.set_parameter(handle => h1, name => 'SKIP_UNUSABLE_INDEXES',
value => 0);
end;
begin
dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0);
end;
begin
dbms_datapump.detach(handle => h1);
end;
end;
/
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 249
Oracle 10g Database Associate Lesson 9 Data Administration
ODBA10gDB-OCA-09-19 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Job Execution
Whilst a job is executing, the screen display on the slide is shown for jobs submitted with immediate
execution.
Delayed jobs are added to a Jobs Queue. The current queue can be
displayed from any EM page, Related Links > Jobs.
Selecting this link displays a list of completed and pending jobs. A job
in the queue can be deleted, suspended, restarted, stopped, deleted or
cloned for rerunning.
V2: Page 250 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
ODBA10gDB-OCA-09-20 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Job Activity
Jobs submitted for immediate execution display the confirmation screen above once the job has been
submitted Note that the status is shown as Running.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 251
Oracle 10g Database Associate Lesson 9 Data Administration
ODBA10gDB-OCA-09-21 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Note that some errors may be acceptable for the submitted job, yet the job will still show as failed in
the status screens.
V2: Page 252 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
SQL*Loader Overview
Log
Bad
File SQL*Loader File
Data Discard
base File
ODBA10gDB-OCA-09-22 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
SQL*Loader Overview
The SQL*Loader utility provides for imports from externally generated files.
These files may have been exported from other database products or purchased from commercial list
vendors.
SQL*Loader requires a control file to define the format of one or more input files containing the
data to be imported.
Data files can be fixed length format or separated with field delimiters and separators.
Optionally, selected rows can be ignored (and written to a discard file). Records that are not in the
required format can be written to a bad file for further (re)processing.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 253
Oracle 10g Database Associate Lesson 9 Data Administration
ODBA10gDB-OCA-09-23 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
V2: Page 254 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
SQL*Loader Options
C:\>sqlldr
Valid Keywords:
userid --
ORACLE username/password
control --
control file name
log --
log file name
bad --
bad file name
data --
data file name
discard --
discard file name
discardmax --
number of discards to allow (Default all)
skip --
number of logical records to skip (Default 0)
load --
number of logical records to load (Default all)
errors --
number of errors to allow (Default 50)
rows --
number of rows in conventional path bind array or between
direct path data saves
(Default: Conventional path 64, Direct path all)
bindsize -- size of conventional path bind array in bytes (Default 256000)
silent -- suppress messages during run (header,feedback,errors,discards,
partitions)
direct -- use direct path (Default FALSE)
parfile -- parameter file: name of file that contains parameter
specifications
parallel -- do parallel load (Default FALSE)
file -- file to allocate extents from
skip_unusable_indexes -- disallow/allow unusable indexes or index partitions
(Default FALSE)
skip_index_maintenance -- do not maintain indexes, mark affected indexes as
unusable (Default FALSE)
commit_discontinued -- commit loaded rows when load is discontinued
(Default FALSE)
readsize -- size of read buffer (Default 1048576)
external_table -- use external table for load; NOT_USED, GENERATE_ONLY, EXECUTE
(Default NOT_USED)
columnarrayrows -- number of rows for direct path column array (Default 5000)
streamsize -- size of direct path stream buffer in bytes (Default 256000)
multithreading -- use multithreading in direct path
resumable -- enable or disable resumable for current session (Default FALSE)
resumable_name -- text string to help identify resumable statement
resumable_timeout -- wait time (in seconds) for RESUMABLE (Default 7200)
date_cache -- size (in entries) of date conversion cache (Default 1000)
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 255
Oracle 10g Database Associate Lesson 9 Data Administration
7000|Geoffrey|Manager|6001|15-JAN-03|10000.0|0.0|10|
7000|Geoffrey|Manager|6001|15-JAN-03|10000.0|0.0|10|
7001|Chris|Developer|6001|15-JAN-03|9000.0|0.0|20|
7001|Chris|Developer|6001|15-JAN-03|9000.0|0.0|20|
7002|Barbara|Programmer|6001|15-JAN-03|9500.0|0.0|10|
7002|Barbara|Programmer|6001|15-JAN-03|9500.0|0.0|10|
7003|Sion|Developer|6001|15-JAN-03|10000.0|0.0|20|
7003|Sion|Developer|6001|15-JAN-03|10000.0|0.0|20|
7004|Willie|Chairman|6001|15-JAN-03|8000.0|6000.0|10|
7004|Willie|Chairman|6001|15-JAN-03|8000.0|6000.0|10|
7005|John|Developer|6001|15-JAN-03|10000.0|0.0|20|
7005|John|Developer|6001|15-JAN-03|10000.0|0.0|20|
7006|Matthew|Support|6001|15-JAN-03|10000.0|0.0|10|
7006|Matthew|Support|6001|15-JAN-03|10000.0|0.0|10|
7007|Michelle|Administrator|6001|15-JAN-03|7500.0|0.0|20|
7007|Michelle|Administrator|6001|15-JAN-03|7500.0|0.0|20|
7008|Jaye|Manager|6001|15-JAN-03|8500.0|4000.0|20|
7008|Jaye|Manager|6001|15-JAN-03|8500.0|4000.0|20|
7009|Jeremy|Instructor|6001|15-JAN-03|11000.0|0.0|10|
7009|Jeremy|Instructor|6001|15-JAN-03|11000.0|0.0|10|
...
...
ODBA10gDB-OCA-09-24 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Data File
SQL*Loader data files can be read in a variety of formats. One example of a delimited file is
illustrated on the slide (Ch09Employees.txt); other examples are illustrated below:
V2: Page 256 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
LOAD
LOAD DATA
DATA
APPEND
APPEND
INTO
INTO TABLE
TABLE SCOTT.NEWEMP
SCOTT.NEWEMP
FIELDS
FIELDS TERMINATED
TERMINATED BY
BY '|'
'|' OPTIONALLY
OPTIONALLY ENCLOSED
ENCLOSED BY
BY ''
''
((
EMPNO
EMPNO INTEGER
INTEGER EXTERNAL,
EXTERNAL,
ENAME
ENAME CHAR,
CHAR,
JOB
JOB CHAR,
CHAR,
MGR
MGR INTEGER
INTEGER EXTERNAL,
EXTERNAL,
HIREDATE
HIREDATE DATE,
DATE,
SAL
SAL INTEGER
INTEGER EXTERNAL,
EXTERNAL,
COMM
COMM INTEGER
INTEGER EXTERNAL,
EXTERNAL,
DEPTNO
DEPTNO INTEGER
INTEGER EXTERNAL
EXTERNAL
))
ODBA10gDB-OCA-09-25 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Control File
A SQL*Loader control file is used to define the structure and actions to be taken with the data file
identified. The sample on the slide above corresponds to the data file on the previous slide.
The following examples also correspond to the examples on the previous page.
LOAD DATA INFILE 'ulcase2.dat' INTO TABLE EMP
( EMPNO POSITION(01:04) INTEGER EXTERNAL,
ENAME POSITION(06:15) CHAR,
JOB POSITION(17:25) CHAR,
MGR POSITION(27:30) INTEGER EXTERNAL,
SAL POSITION(32:39) DECIMAL EXTERNAL,
COMM POSITION(41:48) DECIMAL EXTERNAL,
DEPTNO POSITION(50:51) INTEGER EXTERNAL)
Sample fixed length format control file
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 257
Oracle 10g Database Associate Lesson 9 Data Administration
Executing SQL*Loader
ODBA10gDB-OCA-09-26 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Executing SQL*Loader
SQL*Loader can be executed via the OS command line, using the sqlldr command as described on
page 255.
To perform an external load using Enterprise Manager, select Maintenance > Data Movement > Move
Row Data > Load Data from User Files.
This invokes the EM wizard, which can create all necessary control and log files.
As with import and export commands, SQL*Loader jobs can be scheduled for later,
unattended execution.
V2: Page 258 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
ODBA10gDB-OCA-09-27 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
The first step in the Load Data wizard requests a choice of one of these options.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 259
Oracle 10g Database Associate Lesson 9 Data Administration
ODBA10gDB-OCA-09-28 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
V2: Page 260 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
ODBA10gDB-OCA-09-29 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 261
Oracle 10g Database Associate Lesson 9 Data Administration
ODBA10gDB-OCA-09-30 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Load Method
SQL*Loader (in common with the import/export utilities) allows for several loading
methods to be used. These include:
Conventional Load Populates existing blocks in the segment. Slower but economical on disk
space
Direct Load Populates blocks above the segment high water mark; faster but may
require more space for the object
Parallel Direct Load As Direct Load but uses multiple processes; fastest loading method
V2: Page 262 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
ODBA10gDB-OCA-09-31 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Load Options
Sundry load options can be specified for each load job.
Number of Rows to Load A sample of rows can be loaded by setting this option
Skip Initial rows If a sample had been loaded, skip already loaded rows
Maximum Errors Abort the run if this many errors are found
Maximum Discards Abort the run if this many rows are discarded
Allow Unusable Indexes Load data even if indexes on table are invalid / unusable
Bad File Location and name of optional file for bad (unloaded) rows
Discard File Location and name of optional file for discarded rows
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 263
Oracle 10g Database Associate Lesson 9 Data Administration
SQL*Loader: Schedule
ODBA10gDB-OCA-09-32 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Schedule
As with import/export jobs, a SQL*Loader job can be run immediately or scheduled for later
execution. An optional job name and description can be entered for future reference to the job on the
job queue.
V2: Page 264 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
SQL*Loader: Review
ODBA10gDB-OCA-09-33 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Review
Before executing the load, the Review screen displays a summary of the job and options.
The Show Parameters button can be used to display the SQL*Loader options that will be used to
invoke the job.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 265
Oracle 10g Database Associate Lesson 9 Data Administration
SQL*Loader: Confirmation
ODBA10gDB-OCA-09-34 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Confirmation
The final confirmation screen displays the queueing status for the SQL*Loader job.
V2: Page 266 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
ODBA10gDB-OCA-09-35 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Completion Report
After a SQL*Loader job has executed, whether immediately or queued, a completion report screen is
displayed.
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 267
Oracle 10g Database Associate Lesson 9 Data Administration
Summary
ODBA10gDB-OCA-09-36 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Summary
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
V2: Page 268 Copyright 2007 Jeremy Russell & Associates Ltd.
Lesson 9 Data Administration Oracle 10g Database Associate
Practice 9
ODBA10gDB-OCA-09-37 Copyright Jeremy Russell & Associates, 2007. All rights reserved.
Practice 9
In this practice, you will execute miscellaneous data management tasks.
Create a copy of SCOTT.EMP owned by SYSTEM; dont copy the original data. Use the command below
to create the copy (Ch09CreateNewemp.sql):
________________________________________________________________________
________________________________________________________________________
Create a directory called MyExport. Use EM to create the directory object and open an OS
command window to create a physical directory with an appropriate name. Remember that OS
directory (and file) names are case sensitive on Unix or Linux systems.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Copyright 2007 Jeremy Russell & Associates Ltd. V2: Page 269
Oracle 10g Database Associate Lesson 9 Data Administration
V2: Page 270 Copyright 2007 Jeremy Russell & Associates Ltd.