Download as pdf or txt
Download as pdf or txt
You are on page 1of 92

Oracle DBA Concise Handbook

Oracle DBA Concise


Handbook
Covers 9i to 11g
Saikat Basak
Published by Ensel Software
www.enselsoftware.com
- -
Oracle DBA Concise Handbook
! Saikat Basak
"he author and #ublisher of this book ha$e used their best efforts in #re#arin%
this book. "hese efforts include the de$elo#ment& research and testin% of the
theories and #ro%rams to determine their effecti$eness. "he author and
#ublisher shall not be liable in any e$ent for the incidental or conse'uential
dama%es in connection with& or arisin% out of& the furnishin%& #erformance& or
use of these #ro%rams.
All ri%hts reser$ed. (o #art of this book may be re#roduced& in any form or by
any means& without the #ermission in writin% from the author.

st
Edition )**+
)
nd
Edition )**, - u#dated for *% . %
/ast u#dated 0ul )**
- ) -
Oracle DBA Concise Handbook
Contents
INTRODUCTION ............................................................................................. 6
1 ORAC! "!R#!R $ AN O#!R#I!% ........................................................ &
. /O12CA/ S"34C"43E ........................................................................................ 5
.) O3AC/E 6E6O37 S"34C"43E ............................................................................ 5
.8 BAC913O4(D P3OCESSES .................................................................................. ,
.+ 2(S"A//2(1 A(D 6A(A12(1 O3AC/E DA"ABASE ................................................. )
.: O3AC/E 6A(A1ED ;2/ES <O6;= .................................................................. )
.> C3EA"2(1 A (E? DA"ABASE ........................................................................... )
.5 S"A3"2(1 4P DA"ABASE 2(S"A(CE ................................................................... :
.@ SH4""2(1 DO?( DA"ABASE 2(S"A(CE .............................................................. :
., CO("3O/ ;2/E ............................................................................................... :
.* 3EDO /O1 ;2/ES ......................................................................................... 5
. "AB/E SPACES ........................................................................................... )*
.) SE16E(" A(D S"O3A1E S"34C"43ES ............................................................. )8
.8 "AB/ES .................................................................................................... )+
.+ 2(DEAES ................................................................................................... ):
.: CO(S"3A2("S ........................................................................................... )5
.> 4SE3S A(D SEC432"7 ................................................................................. ),
' BAC(U) AND R!CO#!R* ....................................................................... +'
). 2("3OD4C"2O( .............................................................................................. 8)
).) BAC94P A(D 3ECOBE37 2( (O A3CH2BE /O1 6ODE ............................................. 8)
).8 BAC94P 2( A3CH2BE /O1 6ODE ....................................................................... 8)
).+ 4SE3 6A(A1ED CO6P/E"E 3ECOBE37 .............................................................. 88
).: 4SE3 6A(A1ED 2(CO6P/E"E 3ECOBE37 ............................................................ 8+
).> /O12CA/ BAC94P - EAPO3"C26PO3" A(D DA"A P46P ........................................ 8+
).5 SD/ /OADE3 .............................................................................................. 8>
).@ (E"?O392(1 ;4(DA6E("A/S ......................................................................... 85
)., /O1 62(E3 .................................................................................................. 8,
).* 3EA/ APP/2CA"2O( C/4S"E3S <3AC= ......................................................... +)
). S"A(DB7 DA"ABASE <A/SO O3AC/E DA"A 14A3D= ........................................ ++
).) 3EP/2CA"2O( ............................................................................................. ++
+ )!R,OR-ANC! TUNIN. ......................................................................... /0
8. "4(2(1 DEBE/OP6E(" A(D P3OD4C"2O( S7S"E6S .............................................. +:
8.) SO43CES O; "4(2(1 2(;O36A"2O( ................................................................... +:
8.8 CO//EC"2(1 S"A"2S"2CS ................................................................................. +>
8.+ O3AC/E S4PP/2ED 142 "4(2(1 "OO/S ............................................................. +5
8.: SD/ APP/2CA"2O( "4(2(1 A(D DES21( ............................................................ +5
8.> OP"262EE3 ................................................................................................... +,
- 8 -
Oracle DBA Concise Handbook
8.5 "4(2(1 SHA3ED POO/ .................................................................................... :)
8.@ "4(2(1 DA"ABASE B4;;E3 CACHE .................................................................... :+
8., SHA3ED SE3BE3 ............................................................................................ :>
8.* /A31E POO/ A(D 0ABA POO/ ....................................................................... :5
8. "4(2(1 3EDO ............................................................................................ :5
8.) "4(2(1 A3CH2B2(1 OPE3A"2O(S ................................................................... :@
8.8 "4(2(1 D2S9 2CO ....................................................................................... :@
8.+ "4(2(1 SO3"S ........................................................................................... :@
8.: "4(2(1 3O//BAC9 SE16E("S ...................................................................... :,
8.> /OC9S ...................................................................................................... :,
8.5 "4(2(1 OPE3A"2(1 S7S"E6 ......................................................................... >*
8.@ A4"O6A"2C ?O39/OAD 3EPOS2"O37 <A?3= .............................................. >*
8., A4"O6A"2C DA"ABASE D2A1(OS"2C 6O(2"O3 <ADD6= A(D SD/ "4(2(1
ADB2SO3 ............................................................................................................ >*
/ "1 AND )2"1 ......................................................................................... 6'
+. CO6P2/2(1 PAC9A1ES .................................................................................... >)
+.) 3ECO3DS A(D "AB/ES .................................................................................. >)
+.8 C43SO3 ....................................................................................................... >)
+.+ 6E31E& 64/"2 - "AB/E 2(SE3" A(D P2BO" 2(SE3" ............................................. >8
+.: SD/ 0O2(S .................................................................................................. >+
+.> 4SE;4/ SD/ ;4(C"2O(S ............................................................................... >:
+.5 D7(A62C P/CSD/ ....................................................................................... >>
+.@ (ES"ED "AB/E .............................................................................................. >5
+., "7PES O; 0O2(S ............................................................................................. >@
+.* EA"E3(A/ "AB/ES ...................................................................................... 5*
0 DB-" )AC(A.!" ....................................................................................... &1
:. DB6SF0OB .............................................................................................. 5
:.) 4"/F;2/E ................................................................................................ 5
6 U"!,U "CRI)T" ,OR DBA" ................................................................... &+
>. "O SHO? P326A37C;O3E21( 9E7 3E/A"2O(SH2PS O; A// "AB/ES A(D B2E?S 2( A
12BE( SCHE6A .................................................................................................... 58
>.) "O SEE A// OB0EC"S 2( A "AB/E SPACE ;2/E ...................................................... 58
>.8 ?H2CH 4SE3 EAEC4"2(1 ?HA" "7PE O; CO66A(D ............................................. 5+
>.+ 1E" O4"P4" O; A D4E37 "O A "EA" ;2/E ;3O6 SD/ P/4S ................................. 5+
>.: "O SEE S2EE O; 7O43 "AB/ES A(D 2(DEAES ....................................................... 5+
>.> "O SEE ;3EE SPACES 2( "AB/E SPACES .............................................................. 5+
& N!% ,!ATUR!" O, 13211. ...................................................................... &6
5. ?HA" 2S 1 2( O3AC/EGS 132D CO6P4"2(1H ....................................................... 5,
5.) ?HA" A3E O3AC/E ;4S2O( 62DD/E?A3E <O;6= A(D SE3B2CE O32E("ED
A3CH2"EC"43E <SOA=H ...................................................................................... @*
- + -
Oracle DBA Concise Handbook
4 DBA INT!R#I!% 1U!"TION" ................................................................ 4+
@. OPE(-E(DED D4ES"2O(S ................................................................................. @8
@.) "ECH(2CA/ D4ES"2O(S ................................................................................... @8
@.8 D4ES"2O(S 7O4 SHO4/D AS9 .......................................................................... ,*
9 R!,!R!NC!" ............................................................................................... 91
13 ORAC! "!R#!R5" DIA.RA--ATIC O#!R#I!% ....................... 9'
- : -
Oracle DBA Concise Handbook
Introduction
"here are se$eral books a$ailable in the market for Oracle DBAs. So what is
s#ecial about this bookH
?ell& the differences are se$eral. ;irst of all& this book is a$ailable in electronic
format. 7ou can carry this book where$er you want. 2t is written in sim#le
?ord format <PD; format is also a$ailable=. So& you can o#en it in almost
anywhere. "his book is based on the commands necessary for re%ular DBA
acti$ities. "his is a concise book. 2t attem#ts to be your first reference for DBA
Iob. 7ou will still re'uire lookin% at Oracle manuals and other hu%e references
for ad$anced commands and features. Please note that this book does not try to
teach you how to be a DBA. 2t is assumed that you know a bit of DBA
acti$ities. 2t only acts as a DBA handbook.
2 included a section on common DBA inter$iew 'uestions. ?here do you find
such information in other booksH Some a$id readers wanted the answers to be
%i$en alon% with. Howe$er& some 'uestions are too easy. Some difficult
answersChints ha$e been #ro$ided. But 2 donJt a##reciate #ro$idin% all answers
because unless you ha$e sound understandin% of the conce#t& you can be $ery
easy bo%%ed down by some twists in the 'uestions.
"his is really a CO(C2SE handbook. "hatJs why 2 couldnJt co$er e$ery nuts
and bolts of Oracle. Had 2 do so& this book would ha$e consisted of more than
*** #a%es and its charm would ha$e been lostK Only the most basic as#ects
ha$e been touched. So& #lease donJt yell that why such and such to#ics ha$e
been left. Howe$er& if readers stron%ly feel that some to#ics need to be added& 2
shall definitely honor that demand.
2 shall occasionally u#date the book. So& #lease $isit the website fre'uently to
download latest $ersion of the book.
Please note that ori%inally 2 wrote this book for Oracle ,i and then u#dated for
%.
- > -
Oracle DBA Concise Handbook
1 Oracle Server an overview
1.1 Logical structure
Physical stora%e structures
Oracle database consists of 8 ty#es of #hysical files -
Data files - contains all database data
3edo lo% files - record all chan%es made to data. 4sed for reco$ery
Control files - maintains information about #hysical structure of database
1.2 Oracle memory structure
1.2.1 SGA
System 1lobal Area <S1A= is shared memory area. All users of database share
information maintained in this area. "he S1A and other back%round #rocesses
constitute an Oracle instance.
S1A siLe is limited by S1AF6AAFS2EE initialiLation #arameter.
;rom %& Oracle can mana%e S1A and P1A com#letely automatically.
- 5 -
S7S"E6
"able
s#ace
"able
s#ace
"able
s#ace )
Database
Se%ment
Se%ment )
"ables#ace Se%ment
EMtent
EMtent
Blocks
Oracle DBA Concise Handbook
Shared memory
;rom %& there are two new com#onents in S1A $iL Streams #ool and 3esult
cache.
(on-shared memory
P1A
"he database buffer cache is the area of memory that caches database data&
holdin% blocks from data files that ha$e been read recently. Before a user can
look at a #iece of information in an Oracle database& it must first reside in the
database buffer cache. Data %ets into this cache based u#on the 6ost 3ecently
4sed al%orithm. Because the most recently and most fre'uently used data is
ke#t in memory& less disk 2CO is necessary& and o$erall database #erformance is
im#ro$ed.
"here are 8 ty#es of buffers - dirty& free and #inned.
- @ -
S1A
Database buffer cache
9ee# 3ecycle Default
3edo lo% buffer cache
/ar%e #ool <o#tional=
0a$a #ool <o#tional=
Shared #ool
Data
dictionary
cache
Control
structures
/ibrary cache
Shared SD/
P/CSD/
#rocedures
. #acka%es
/ocks and
other
structures
Stack s#ace Session info Sort area
Oracle DBA Concise Handbook
Oracle uses an /34 mechanism to remo$e data from DB cache.
DBFCACHEFS2EE& DBF9EEPFCACHEFS2EE&
DBF3EC7C/EFCACHEFS2EE determines DB cache siLe.
DBFCACHEFADB2CE can be set to O(CO;;C3EAD7 and the result can be
$iewed from BNDBFCACHEFADB2CE.
3edo lo% buffer is a circular buffer in S1A that holds information about
chan%es made to data.
/O1FB4;;E3 determines its siLe.
1.2.2 Shared pool
/ibrary cache contains shared SD/ area& P/CSD/ #rocedures and #acka%es etc.
2t is used for maintainin% recently eMecuted SD/ commands and their eMecution
#lans.
Data dictionary cache is a collection of database tables and $iews containin%
metadata about the database& its structures& its #ri$ile%e and its users. Oracle
accesses data dictionary fre'uently durin% #arsin% of SD/ statements. Data
dictionary cache holds most recently used data dictionary information.
SHA3EDFPOO/FS2EE determines siLe of shared #ool and can be dynamically
altered.
P1A contains data and information for sin%le ser$er #rocess.
P1AFA113E1A"EF"A31E" s#ecifies total amount of memory that can be
used by all ser$er #rocesses.
1.3 Background processes
1.3.1 Database Writer (DWn!
Oracle marks buffers in memory as dirty when the data they contain is chan%ed.
DB?n writes content of dirty buffer to data file when - a ser$er #rocess canJt
find a clean buffer after searchin% set threshold of buffers& a check#oint occurs&
chan%e table s#ace to read onlyCofflineCbacku# mode& dro#Ctruncate table etc.
- , -
Oracle DBA Concise Handbook
1.3.2 "o# Writer ("GW$!
2t is res#onsible to redo lo% buffer mana%ement. Almost all acti$ities a%ainst the
database are tracked in the online redo lo%s. As transaction are initiated and
e$entually committed or rolled back& a record of this acti$ity is written to these
lo% files.
/o% writer writes to redo lo%s se'uentially.
1.3.3 %hec&point (%'()!
Hel#s to reduce time re'uired for instance reco$ery. A check#oint is an e$ent
that flushes modified data from buffer cache to disk and u#dates control file and
data files. "he C9P" #rocess u#dates header of data files and control files and
DB?n writes actual blocks to file. Check#oint occurs automatically when an
online redo lo% file fills <lo% switch=.
1.3.* S+ste, -onitor (S-O.!
At startu#& S6O(Js Iob is to ensure that all the database files are consistent and
#erform reco$ery if re'uired. "here is also an assortment of other cleanu#
acti$ities that may need to be done& which are S6O(Js res#onsibility. "he
S6O( #rocess by itself checks e$ery so often to see whether there are any tasks
waitin% for its attention.
1.3./ (rocess -onitor ((-O.!
Cleans u# failed user #rocesses and frees all resources used by failed #rocess.
1.3.0 Archiver (A$%n!
2t automatically sa$es co#ies of redo lo%s in a DBA s#ecified stora%e location
when media reco$ery is enabled.
1.3.1 $ecover ($2%O!
2s used with distributed transaction to resol$e failure.
- * -
Oracle DBA Concise Handbook
1.3.3 "oc& ("%'n!
2t is used in 3AC.
1.3.4 Dispatcher (Dnnn! 5 Shared Server (Snnn!
"hese are discussed later.
1.3.16 -ana#eabilit+ ,onitor (--O.!
;rom *%& it makes sna#shots of the databaseJs health <statistics= and stores this
information in the automatic workload re#ository.
1.3.11 (rocessin# S7"
"he followin% ste#s show how Oracle #rocesses SD/
. Statement is #assed to Oracle for #rocessin%
). Before it is #laced in the library cache& a hash $alue is com#uted that
re#resent s a number of characteristics of the SD/.
8. Oracle com#ares the com#uted hash $alue a%ainst those $alues in a hash
table where it maintains for SD/ statements already in the cache.
+. 2f a match is found& the new SD/ statement is thrown away and the one
sittin% in the cache is eMecuted on its behalf.
:. 2n no match is found& further #rocessin% is done on the new SD/
statement& an entry is made in the library cache hash table for newly
arri$ed code& and it is #laced in the library cache.
>. "here are 8 sta%es of SD/ #rocessin% - #arse& eMecute and fetch
Durin% #arsin%& Oracle ser$er checks the syntaM and $alidates
table& column names a%ainst data dictionary
Determines whether user has #ri$ile%e to eMecute the statement
Determines o#timal eMecution #lans for statement
;inds a shared SD/ area for the statement
2n eMecution sta%e& for 4PDA"E and DE/E"E statement& Oracle
locks the affected rows& looks for data blocks in DB buffer cache&
if found& eMecutes becomes faster& if not then Oracle has to read
from #hysical data files to buffer cache. ;or SE/EC" and 2(SE3"
statements& lockin% is not necessary.
Durin% fetch o#eration& rows are fetched to user #rocess.
- -
Oracle DBA Concise Handbook
1.4 Installing and managing Oracle database
"o use o#eratin% system authentication& set
3E6O"EF/O12(FPASS?O3D;2/E #arameter to (O(E <default=.
OS authenticated users can connect as CO((EC" C AS S7SDBA <or
S7SOPE3=.
?hen usin% #assword file authentication& users connect to database by
s#ecifyin% username and #assword.
. 4sin% O3AP?D utility& create a #assword file with S7S #assword.
). Set 3E6O"EF/O12(FPASS?O3D;2/E #arameter.
8. 1rant a##ro#riate users S7SDBA or S7SOPE3 #ri$ile%e.
1.5 Oracle Managed Files OMF!
Set followin% #arameters in initialiLation file.
DBFC3EA"EF;2/EFDES" - default location of new datafiles
DBFC3EA"EFO(/2(EF/O1FDES"Fn - s#ecifies location for online lo% files
and control files <maM. : locations=
"o create database usin% O6;& use
C3EA"E DA"ABASE 67DB DE;A4/" "E6PO3A37 "AB/ESPACE
"6PO
1." #reating a ne$ database
4sually when you install Oracle& it automatically creates a database for you
<thou%h you need to s#ecify a database name for this=. Otherwise& you usually
use %ra#hical Database Confi%uration Assistant <DBCA= to createCmana%e
databases. So& you may not e$en re'uire creatin% a database from command
#rom#t. Howe$er& in case you need to& the ste#s are shown below.
2n OS command #rom#t& use
- ) -
An Oracle instance consists of memory structures <S1A= and
back%round #rocesses <DB?n& /1?3& C9P"& S6O(& P6O(&
66O( and o#tionally A3Cn& Dnnn& Snnn etc.=
Oracle DBA Concise Handbook
O3AD26 -(E? -S2D sidFname -2("P?D sysF#assword -6AA4SE3S *
2n ?indows& %o to Control Panel - Ser$ices
Check ser$ice named OracleSer$iceS2D started.
2n 6y Com#uter& En$ironment tab& define
O3AC/EFS2DPsidFname
Create folders where you want to kee# database files e%.
;QR67DBRDA"A;2/ES& 4D46P& BD46P& CD46P& /O1S& A3CH2BE etc.
Create a new initS2D.ora file with rele$ant #arameters
BAC913O4(DFD46PFDES"P;QR67DBRBD46P
CO3EFD46PFDES"P;QR67DBRCD46P
4SE3FD46PFDES"P;QR67DBR4D46P
DBF(A6EP sidFname
2(S"A(CEF(A6EP sidFname
4(DOF6A(A1E6E("PA4"O
4(DOF"AB/ESPACEP4(DO*
Start SD/ Plus
C AS S7SDBA
S"A3"4P (O6O4("
C3EA"E DA"ABASE 67DB
6AADA"A;2/ES 8*
6AA/O1;2/ES *
6AA/O16E6BE3S :
6AA2(S"A(CES
6AA/O1H2S"O37
DA"A;2/E G;QR67DBRDA"A;2/ESRS7S"E6*.DB;G S2EE **6
/O1;2/E
13O4P G;QR67DBR/O1R/O1*.DB;G S2EE *6&
13O4P ) G;QR67DBR/O1R/O1*).DB;G S2EE *6
4(DO "AB/ESPACE 4(DO*
DA"A;2/E G;QR67DBR4(DOR4(DO*.DB;G S2EE :*6
DE;A4/" "E6PO3A37 "AB/ESPACE "E6P
"E6P;2/E G;QR67DBR"E6PR"E6P*.DB;G S2EE *6
CHA3AC"E3 SE" ?E@6S?2():)
C
- 8 -
Oracle DBA Concise Handbook
C3EA"E SP;2/E ;3O6 P;2/EO
(oteQ Abo$e command was for Oracle ,i. ;rom *%& you need SysauM table
s#ace as well.
(ow run calalo%.s'l <creates data dictionary $iews= and cat#roc.s'l <creates P/C
SD/ #acka%es= from NO3AC/EFHO6ER3DB6SRAD62(
After installin% Oracle& se$eral ser$ices are re%istered in the ser$er com#uter. 2n
?indows& <for Oracle ,.)= followin% ser$ices must be started as a minimum to
run Oracle - OracleOraHome,)A%ent& OracleOraHome,)"(S/istener and
OracleSer$iceS2D <where S2D is the name of database you created=.
2n ?indows Bista runnin% Oracle %& 2 usually startCsto# my test database $ia
followin% batch file <say StartOracle.bat MYDB is name of my database=
net start OracleServiceMYDB
net start OracleOraDb11g_home1TNSListener
net start OracleVssWriterMYDB
net start OracleDBConsoleMYDB
"o sto# database ser$ices& you can create a similar batch file by re#lacin% start
with stop. 2n Bista& you need to run these batch files as administrator.
2f you do not start OracleDBConsoleSS2DT ser$ice& then you wonJt be able to
start web based Enter#rise 6ana%er - which you usually start from
htt#sQCClocalhostQ:@Cem <where localhost may be substituted for your
com#uter name=
7ou usually lo% on to Oracle ser$er from USQL PlusV as -
S7SCPASS?O3DWDA"ABASE(A6E AS S7SDBA. Sometimes you can
also lo% in as sim#ly UC AS S7SDBAV only when you are #hysically in the same
com#uter where Oracle ser$er is installed. Please note that Ser$er 6ana%er tool
is no lon%er a$ailable from Oracle ,i onwards. 7ou can do e$erythin% usin%
SD/ PlusK
;or $arious day-to-day database works& you may find SD/ Plus cumbersome to
work with. ;or this& se$eral 8
rd
#arty 142 tools are a$ailable. "wo most #o#ular
tools are - P/CSD/ De$elo#ers and "OAD. ;rom %& ?indows SD/ Plus has
been re#laced by SD/ De$elo#er suite bundled with %. DOS $ersion of SD/
Plus is still a$ailable thou%hK
- + -
Oracle DBA Concise Handbook
1.% &tarting up database instance
SD/T S"A3"4P (O6O4("
"his state is used for creatin% new database or creatin% new control file. At this
state& Oracle allocates S1A and starts back%round #rocesses.
SD/T S"A3"4P 6O4("
"his state is used for #erformin% s#ecific maintenance o#erations like renamin%
data files& enablin%Cdisablin% archi$e lo% mode& addin%Cdro##in%Crenamin% redo
lo% files& reco$erin% database etc. Control file is read at this sta%e but the data
files are not o#en.
SD/T S"A3"4P OPE( or sim#ly SD/TS"A3"4P
Database is a$ailable for normal o#erations.
(BQ Oracle % re'uires at least 1B of 3A6 and : 1B disk s#ace to install.
;or an o#erational #roduction database& more 3A6 and disk s#ace are re'uired.
1.' &(utting do$n database instance
SD/T SH4"DO?( (O36A/ or sim#ly SD/T SH4"DO?(
?aits for all database users to disconnect then closes database.
SD/T SH4"DO?( 266ED2A"E
"erminates all user connections& rolls back uncommitted transactions& closes
database.
SD/T SH4"DO?( "3A(SAC"2O(A/
?aits for all transactions to commit or roll back& then closes database.
SD/T SH4"DO?( ABO3"
2mmediately closes database lea$in% it in inconsistent state. S6O(
automatically #erforms instance reco$ery durin% neMt startu#.
1.) #ontrol *ile
Control file contains -
Database name
Database creation timestam#
Data files - name& location& onCoff line status
3edo lo% files - name& location
3edo lo% archi$e information
- : -
Oracle DBA Concise Handbook
"able s#ace names
Current lo% se'uence number
6ost recent check#oint information
Be%in and end of undo se%ments
36A( backu# information
Oracle backs u# control file after any structural chan%es in database. /1?3
u#dates control file with current lo% se'uence number. C9P" u#dates control
file with recent check#oint information. A3Cn u#dates with archi$in%
information.
1.4.1 -ultiple8in# control 9iles
4sin% init.ora
CO("3O/F;2/ES P
<XCoraCoradataCmydbCcontrol.ctlJ& XCoraCoradataCmydbCcontrol.ctlJ=
4sin% s#file
. SD/T A/"E3 S7S"E6 SE" CO("3O/F;2/ES P <XCoraCoradataCmydbC
control.ctlJ& XCoraCoradataCmydbCcontrol.ctlJ= SCOPEPSP;2/E
). SD/TSH4"DO?( (O36A/
8. Co#y control file to new location
+. SD/TS"A3"4P
"o create O6; control files& donJt s#ecify CO("3O/F;2/ES #arameter in
initialiLation fileO rather s#ecify DBFC3EA"EFO(/2(EF/O1FDES"Fn
#arameter n times startin% with .
1.4.2 %reatin# new control 9ile
6ake sure you ha$e com#lete list of all data and lo% files.
2n SD/ Plus& write <the database should be in S"A3"4P (O6O4("=
C3EA"E CO("3O/;2/E SE" DA"ABASE U67DBV
(O3ES"/O1S (OA3CH2BE/O1
6AADA"A;2/ES 8*
6AA/O1;2/ES *
- > -
Oracle DBA Concise Handbook
6AA/O16E6BE3S :
6AA2(S"A(CES
6AA/O1H2S"O37
DA"A;2/E
G;QR67DBRDA"A;2/ESRS7S"E6*.DB;G
G;QR67DBRDA"A;2/ESR4SE3S*.DB;G
G;QR67DBRDA"A;2/ESR4(DO*.DB;G
G;QR67DBRDA"A;2/ESR"E6P*.DB;G
/O1;2/E
13O4P G;QR67DBR/O1R/O1*.DB;G S2EE *6&
13O4P ) G;QR67DBR/O1R/O1*).DB;G S2EE *6
C
"o back u# control file when database is runnin%& use
A/"E3 DA"ABASE BAC94P CO("3O/;2/E "O filename 3E4SE
Or
A/"E3 DA"ABASE BAC94P CO("3O/;2/E "O "3ACE - it #laces a teMt
co#y of control file to 4SE3FD46PFDES" directory.
2f Oracle canJt u#date control file& instance crashes.
1.4.3 %ontrol 9ile related data dictionar+ views
BNCO("3O/;2/E
BNCO("3O/;2/EF3ECO3DFSEC"2O(
1.1+ ,edo log *iles
3edo entries record data chan%es that can be used to reconstruct all chan%es
made to database. ?hene$er you do any chan%e to database <D6/ or DD/=& it
is recorded in redo lo%s.
"o o#erate successfully& an Oracle instance re'uires at least ) redo lo% %rou#s.
Each %rou# must ha$e at least redo lo% file.
4sually in #roduction databases& there are at least 8 redo lo% %rou#s and each
%rou# has at least ) redo lo% members. (ote that& all member files under same
%rou# are identical. 6embers are multi#le co#ies to #rotect a%ainst data loss in
case of disk failure.
- 5 -
Oracle DBA Concise Handbook
2f /1?3 can write to at least member of the %rou#& database functions
normally& but otherwise Oracle shuts down the instance.
1.16.1 %reatin# new #roups and ,e,bers
A/"E3 DA"ABASE ADD /O1;2/E 13O4P 8
<XCoracleCoradataClo%Credo8.lo%J& XCoracleCoradataClo%Credo8).lo%J= S2EE *6
A/"E3 DA"ABASE ADD /O1;2/E 6E6BE3
XCoracleCoradataClo%Credo8.lo%J "O 13O4P 8
;or O6;
A/"E3 DA"ABASE ADD /O1;2/E
- @ -

)
8
3edo lo% files
8 %rou#s and
8 members
each
1rou# 1rou# ) 1rou# 8
Oracle DBA Concise Handbook
1.16.2 $ena,in# lo# ,e,bers
;ollow these ste#s
Shutdown database
Co#yCrename redo lo% file member to new location
SD/T S"A3"4P 6O4("
A/"E3 DA"ABASE 3E(A6E ;2/E old redo lo% file "O new redo lo%
file
A/"E3 DA"ABASE OPE(
Backu# control file
1.16.3 Droppin# redo lo# 9ile
;irst& make the lo% file inacti$e& if necessary& issue A/"E3 S7S"E6 S?2"CH
/O1;2/E
A/"E3 DA"ABASE D3OP /O1;2/E 13O4P 8
A/"E3 DA"ABASE D3OP /O1;2/E 6E6BE3
XCoracleCoradataClo%Credo8.lo%J
1.16.* $unnin# database in archive lo# ,ode
S#ecify /O1FA3CH2BEFDES"Fn #arameters in initialiLation file.
E.%. /O1FA3CH2BEFDES"F P <</OCA"2O( P XCoradataCmydbCarchi$eJ=
6A(DA"O37 3EOPE( P >*=
2n %& to enable database archi$e lo% mode& define archi$e location like this
A/"E3 S7S"E6 SE" /O1FA3CH2BEFDES"FPG/OCA"2O(PCQROracle%RoradataR67DBRarchi$elo%G
SCOPEPSP;2/EO <in mount state=
/O1FA3CH2BEF;O36A" P XarchFYtFYsJ
Ys - lo% se'uence number
YS - lo% se'uence number& Lero filled
Yt - thread number
Y" - thread number& Lero filled
"o enableCdisable archi$e lo% mode& follow these ste#s
- , -
Oracle DBA Concise Handbook
Shutdown database <lo% in $ia conn C as sysdba=
Startu# and mount database
SD/T A/"E3 DA"ABASE A3CH2BE/O1 <use (OA3CH2BE/O1 to
disable=
SD/T A/"E3 DA"ABASE OPE(
"ill ,i& in the initialiLation file& set /O1FA3CH2BEFS"A3" P "34E <if it is
not set& once a redo lo% file is full& Oracle han%s until redo lo% file is archi$ed=.
;rom *%& this #arameter is de#recated.
"o manually initiate automatic archi$in%& issue A/"E3 S7S"E6 A3CH2BE
/O1 S"A3" and A/"E3 S7S"E6 S?2"CH /O1;2/E commands.
"o see whether database is in archi$e lo% mode& use
SD/T A3CH2BE /O1 /2S"
1.16./ $edo lo# related data dictionar+ views
BN/O1 - shows redo lo% status
BN/O1;2/E - shows redo lo% filesJ location
BN"H3EAD
BN/O1FH2S"O37
BNA3CH2BEDF/O1
BNA3CH2BEFDES"
BNA3CH2BEFP3OCESSES
1.11 -able spaces
"he databaseJs data is stored lo%ically in table s#aces and #hysically in data
files corres#ondin% to the table s#aces. One table s#ace can ha$e multi#le data
file but one data file must belon% to only one table s#ace. A sin%le obIect <say a
table= may s#an multi#le data files but must reside within a sin%le table s#ace.
1.11.1 %reatin# table space
C3EA"E "AB/ESPACE su#ermarket DA"A;2/E
GeQRoracleRoradataRmdbRsu#ermarket.dbfG S2EE 8*6
EA"E(" 6A(A1E6E(" /OCA/ A4"OA//OCA"E SE16E(" SPACE
6A(A1E6E(" A4"O
- )* -
Oracle DBA Concise Handbook
C3EA"E "AB/ESPACE su#ermarket DA"A;2/E
GeQRoracleRoradataRmdbRsu#ermarket.dbfG S2EE 8*6
A4"OEA"E(D O( (EA" *6 6AAS2EE 4(/262"ED
1.11.2 Droppin# table space
D3OP "AB/ESPACE su#ermarket 2(C/4D2(1 CO("E("S A(D
DA"A;2/ES
1.11.3 $ena,in# table space
;rom Oracle *% onwards& you can rename a table s#ace <eMce#t System and
SysauM=
A/"E3 "AB/ESPACE oldFname 3E(A6E "O newFname
?hen you rename a table s#ace& all corres#ondin% data dictionary entries are
u#dated.
1.11.* Availabilit+ o9 table space
A/"E3 "AB/ESPACE su#ermarket O;;/2(E
(O36A/C"E6O3A37C266ED2A"EC;O3 3ECOBE3
7ou canJt #lace System table s#ace in offline mode.
"o make a table s#ace read only&
A/"E3 "AB/ESPACE su#ermarket 3EAD O(/7
"o chan%e it to read write mode&
A/"E3 "AB/ESPACE su#ermarket 3EAD ?32"E
1.11./ Addin# space to table space
A/"E3 "AB/ESPACE su#ermarketFDA"A ADD DA"A;2/E
GcQRoracleRoradataRmydbRsu#ermarketFdata).dbfG S2EE 8*6
A/"E3 DA"ABASE DA"A;2/E
GcQRoracleRoradataRmydbRsu#ermarketFdata).dbfG 3ES2EE 8**6
- ) -
Oracle DBA Concise Handbook
1.11.0 )able space related data dictionar+ views
DBAF"AB/ESPACES - all table s#ace information
BNF"AB/ESPACE
DBAF;3EEFSPACE
BNSO3"F4SA1E
DBAFSE16E("S
DBAF4SE3S - shows default and tem#orary table s#ace for users
1.11.1 $ena,in# and relocatin# 9ile
;ollow these ste#s to rename data file <for sin%le table s#ace eMce#t System
table s#ace=
A/"E3 "AB/ESPACE su#ermarket O;;/2(E
Co#y or mo$e the file to new location with OS commands
A/"E3 DA"ABASE 3E(A6E ;2/E
GcQRoracleRoradataRmydbRsu#ermarketFdata).dbfG "O
GcQRoracleRoradataRmydbRsu#ermarketFnew.dbfG
or
A/"E3 "AB/ESPACE su#ermarket 3E(A6E DA"A;2/E
GcQRoracleRoradataRmydbRsu#ermarketFdata).dbfG "O
GcQRoracleRoradataRmydbRsu#ermarketFnew.dbfG
A/"E3 "AB/ESPACE su#ermarket O(/2(E
2n case of System table s#ace or table s#aces with multi#le data files
Shutdown database
Co#y or mo$e the file to new location with OS commands
Startu# database in mount state
A/"E3 DA"ABASE 3E(A6E ;2/E
GcQRoracleRoradataRmydbRsu#ermarketFdata).dbfG "O
GcQRoracleRoradataRmydbRsu#ermarketFnew.dbfG
O#en database
Please note in case of ?indows& the file may %et locked unless database is
shutdown.
- )) -
Oracle DBA Concise Handbook
1.11.3 Data 9ile related data dictionar+ views
BNDA"A;2/E
BN"E6P;2/E
DBAFDA"AF;2/ES
DBAF"E6PF;2/ES
1.12 &egment and storage structures
PC";3EE P s#ecifies what #ercenta%e of block should be allocated as free
s#ace for future u#dates <default *=
PC"4SED P s#ecifies when the block can be considered for addin% new rows
<default +*=
PC";3EE Z PC"4SED SP **
Blocks are smallest lo%ical unit of stora%e in Oracle database.
An eMtent is lo%ical stora%e unit made of conti%uous data blocks.
Se%ment is lo%ical stora%e unit made u# of one or more eMtents.
"y#es of se%ments are - table& table #artition& cluster& nested table& indeM& indeM
or%aniLed table& indeM #artition& tem#orary& /OB& undo& bootstra#.
1.12.1 :ndo se#,ent
?hen a user #erforms an u#date or deletes o#eration& the earlier data is sa$ed to
undo se%ments and then actual data is modified to new $alue. 2n case of insert
o#eration& rowid of new rows are stored in undo se%ments.
4ndo data is not deleted immediately after commit or rollback. How lon% it will
stay in undo se%ment de#ends on 4(DOF3E"E("2O( #arameter in
initialiLation file.
?hen a transaction is rolled back& Oracle restores the earlier data from undo
se%ments.
;rom Oracle ,i& undo mana%ement can be automatically controlled.
"o use automatic undo mana%ement& set followin% #arameters in initialiLation
file.
4(DOF6A(A1E6E("PA4"O
- )8 -
Oracle DBA Concise Handbook
4(DOF"AB/ESPACEPtable s#ace name
1.12.2 %reatin# undo se#,ent
C3EA"E 4(DO "AB/ESPACE undo DA"A;2/E
XCoradataCmydbCundo*.dbfJ S2EE )*6
"o s#ecify different table s#ace as undo table s#ace dynamically - issue
A/"E3 S7S"E6 SE" 4(DOF"AB/ESPACEPundo*)
1.12.3 28tent or se#,ent related data dictionar+ views
DBAFEA"E("S
DBAF;3EEFSPACE
DBAFSE16E("S
BNSO3"FSE16E("
DBAF3O//BAC9FSE1S
BN3O//(A6E
BN3O//S"A"
BN4(DOS"A"
1.13 -ables
1.13.1 %reatin# tables
Create table 6A(4;AC"43E3
<
6;D(O (46BE3 not null&
6;D(A6E BA3CHA3)<)**= not null&
ADD3ESS BA3CHA3)<)**=&
C2"7 BA3CHA3)<:*=&
S"A"E CHA3<)=&
CO4("37 BA3CHA3)<**=&
POS"CODE BA3CHA3)<*=&
PHO(E BA3CHA3)<:*=&
E6A2/ BA3CHA3)<**=&
4SE3(A6E BA3CHA3)<)*= default 4SE3&
DA"ES"A6P DA"E default S7SDA"E
= tables#ace S4PE36A39E"FDA"A
- )+ -
Oracle DBA Concise Handbook
C3EA"E "AB/E 6A(4;AC"43E3
(O/O112(1 PA3A//E/
AS
SE/EC" [ ;3O6 CO6PA(7
1.13.2 $eor#ani;in# tables
"o mo$e a table to a different table s#ace
A/"E3 "AB/E #roduct 6OBE "AB/ESPACE su#ermarket
1.13.3 Droppin# a table
D3OP "AB/E schema.tableFname <CASCADE CO(S"3A2("S=
"34(CA"E "AB/E tableFname
"runcate resets H?6 where delete does not.
"runcate is not lo%%ed but delete is lo%%ed.
1.13.* -odi9+in# colu,ns
A/"E3 "AB/E schema.tableFname D3OP CO/46( columnFname
<CASCADE CO(S"3A2("S=
A/"E3 "AB/E schema.tableFname SE" 4(4SED CO/46(
columnFname& column)Fname <CASCADE CO(S"3A2("S=
A/"E3 "AB/E #roduct ADD 6fd BA3CHA3)<8*= DE;A4/" XabcJ
1.13./ )able related data dictionar+ views
DBAF"AB/ES
DBAF"ABFCO/46(S - all columns of all tables
1.14 Inde.es
Oracle has mainly ) ty#es of indeMes& BZ "ree and Bitma#.
- ): -
Oracle DBA Concise Handbook
1.1*.1 %reatin# inde8
(ormal B tree indeM
C3EA"E 2(DEA indeMFname O( tableFname <columnFnames=
"AB/ESPACE a##FindM
Bitma# indeM
C3EA"E B2"6AP 2(DEA em#F%enderFidM O( em#loyee <seM=
"AB/ESPACE a##FindM
3e$erse key indeM
C3EA"E 2(DEA indeMFname O( tableFname <columnFnames=
3EBE3SE
;unction based indeM
C3EA"E 2(DEA indeMFname O( 4PPE3<#roduct <#rodname==
"o use function based indeM& set followin% #arameters in initialiLation file
D4E37F3E?32"EFE(AB/EDP"34E
D4E37F3E?32"EF2("E132"7P"34S"ED
Cost based o#timiLer must be used.
1.1*.2 Inde8 Ora#ani;ed )able (IO)!
Create the table normally& with O31A(2EA"2O( 2(DEA keyword. 2t is
suitable when data access is mostly thru #rimary key. 2n 2O"& rows are
#hysically stored in sorted order of the #rimary key.
Create table 6A(4;AC"43E3
<
6;D(O (46BE3 not null&
6;D(A6E BA3CHA3)<)**= not null&
ADD3ESS BA3CHA3)<)**=&
C2"7 BA3CHA3)<:*=&
S"A"E CHA3<)=&
CO4("37 BA3CHA3)<**=&
POS"CODE BA3CHA3)<*=&
- )> -
Oracle DBA Concise Handbook
PHO(E BA3CHA3)<:*=&
E6A2/ BA3CHA3)<**=&
4SE3(A6E BA3CHA3)<)*= default 4SE3&
DA"ES"A6P DA"E default S7SDA"E
= tables#ace S4PE36A39E"FDA"A
O3A1A(2EA"2O( 2(DEA
OBE3;/O? "AB/ESPACE o$flFtbls#
2(C/4D2(1 address
PC""H3ESHO/D ):
6APP2(1 "AB/E
1.1*.3 $ebuildin# inde8
A/"E3 2(DEA #kFcustomer 3EB42/D O(/2(E
D3OP 2(DEA #kFcustomer
7ou can also mo$e indeM to a different table s#ace usin% ALTE !"DE#
inde$%name TABLESPA&E ne'%table%s(ace command.
1.1*.* -onitorin# inde8 usa#e
A/"E3 2(DEA indeM 6O(2"O32(1 4SA1E
"he BNOB0EC"F4SA1E $iew #o#ulated with indeM usa%e information.
A/"E3 2(DEA indeM (O6O(2"O32(1 4SA1E
1.1*./ Inde8 related data dictionar+ views
DBAF2(DEAES
DBAF2(DFCO/46(S
1.15 #onstraints
"y#es of constraints - not null& check& uni'ue& #rimary key& forei%n key
A/"E3 "AB/E table 6OD2;7 column (O" (4//
A/"E3 "AB/E table 6OD2;7 column (4//
A/"E3CC3EA"E "AB/E table <\.=
- )5 -
Oracle DBA Concise Handbook
CO(S"3A2(" ckFbonus check < bonus T * =
A/"E3 "AB/E table ADD CO(S"3A2(" ckFbonus check < bonus T * =
C3EA"E "AB/E #roduct <\.=
CO(S"3A2(" #kF#rodcode P326A37 9E7 <#rodcode=
A/"E3 "AB/E #roduct ADD CO(S"3A2(" #kF#rodcode P326A37 9E7
<#rodcode=
A/"E3 "AB/E #roduct ADD CO(S"3A2(" fkFmfd ;O3E21( 9E7
<mfdby= 3E;E3E(CES manufacturer<mfdno= O( DE/E"E CASCADE
Constraints created are enabled by default. 7ou can create it as disabled by
usin% D2SAB/ED keyword at end of command.
A/"E3 "AB/E table D3OP CO(S"3A2(" constraint
A/"E3 "AB/E table D3OP P326A37 9E7 CASCADE
1.1/.1 2nablin#<disablin# constraints
A/"E3 "AB/E table D2SAB/E CO(S"3A2(" constraint
A/"E3 "AB/E table E(AB/E CO(S"3A2(" constraint
A/"E3 "AB/E table 6OD2;7 CO(S"3A2(" constraint E(AB/E
A/"E3 "AB/E table 6OD2;7 CO(S"3A2(" constraint D2SAB/E
1.1/.2 =alidated constraints
Enable $alidate - default& eMistin% rows and future rows are checked
Enable no$alidate - eMistin% rows not checked but future rows are checked
Disable $alidate - eMistin% rows checked but future rows are not checked <no
D6/ is allowed on table=
Disable no$alidate - no check done on eMistin% or future rows
A/"E3 "AB/E table 6OD2;7 CO(S"3A2(" constraint E(AB/E
(OBA/2DA"E
1.1/.3 De9errin# constraints
- )@ -
Oracle DBA Concise Handbook
2f constraint is created with DE;E3AB/E clause& you can define whether
constraint checkin% will be done immediately <2(2"2A//7 266ED2A"E&
default= or later <2(2"2A//7 DE;E3EED=.
A/"E3 "AB/E name 6OD2;7 CO(S"3A2(" consFname 2(2"A//7
DE;;E3ED <or 266ED2A"E=
1.1/.* Inde8 related data dictionar+ views
DBAFCO(S"3A2("S
DBAFCO(SFCO/46(S
1.1" /sers and security
1.10.1 (ro9ile
Profiles are used to control database resource usa%e. DE;A4/" #rofile is
created at creation time of database. "o enforce resource limit&
3ESO43CEF/262"P"34E should be set in initialiLation file.
C3EA"E P3O;2/E O;;2CEF4SE3 /262"
SESS2O(SFPE3F4SE3 >
CO((EC"F"26E ++*
2D/EF"26E )*
;A2/EDF/O12(FA""E6"S 8
PASS?O3DF/OC9F"26E 4(/262"ED
A/"E3 4SE3 clerk P3O;2/E officeFuser
1.10.2 :sers
C3EA"E 4SE3 696
2DE("2;2ED B7 696
DE;A4/" "AB/ESPACE S4PE36A39E"FDA"A
"E6PO3A37 "AB/ESPACE "E6P
D4O"A 4(/262"ED O( S4PE36A39E"FDA"A
P3O;2/E DE;A4/"
13A(" CO((EC"& 3ESO43CE& SE/EC"FCA"A/O1F3O/E&
EAEC4"EFCA"A/O1F3O/E "O 696
- ), -
Oracle DBA Concise Handbook
D3OP 4SE3 mkm CASCADE
1.10.3 (rivile#e
Pri$ile%es control what users can or canJt do in database.
ObIect #ri$ile%e - #ro$ides #ermission to access schema obIects. 1ranted for
s#ecific obIects.
13A(" SE/EC"& 4PDA"E O( #roduct& #rice "O clerk <?2"H 13A("
OP"2O(=
System #ri$ile%e - #ro$ide ri%ht to #erform structural chan%e in database le$el.
13A(" C3EA"E A(7 "AB/E "O Iohn <?2"H AD62( OP"2O(=
3EBO9E C3EA"E A(7 "AB/E ;3O6 Iohn
;or obIect #ri$ile%es& both %rantor and %rantee information is stored in data
dictionaryO where as for system #ri$ile%e& only %rantee information is stored.
1.10.* $oles
A role is named set of #ri$ile%es.
C3EA"E 3O/E C/E39
13A(" SE/EC"& 2(SE3"& 4PDA"E O( "3A(SAC"2O( "O C/E39
A/"E3 4SE3 Iohn DE;A4/" 3O/E C/E39 <(O(E=
1.10./ :ser related data dictionar+ views
DBAF4SE3S
DBAF"SFD4O"A - s#ace assi%ned to users
BNSESS2O( - users currently connected to database
DBAF"ABFP32BS
DBAFCO/FP32BS
DBAFS7SFP32BS
SESS2O(FP32BS
- 8* -
Oracle DBA Concise Handbook
DBAF3O/ES
DBAF3O/ESFP32BS
3O/EF3O/EFP32BS
- 8 -
Oracle DBA Concise Handbook
2 ac&up and $ecover+
2.1 Introduction
?hen instances crashes for any reason <e.%. Power failure= Oracle automatically
reco$ers when database starts neMt time.
"he most im#ortant decision you need to take for backu# is to decide whether
the database will run in archi$e or no archi$e lo% mode. 4sually #roduction
databases al'ays run in archi$e lo% mode.
2deally& each member of archi$e lo% %rou#s should reside in different #hysical
disks so that if one disk %ets corru#t& identical co#ies can be retrie$ed from
another disk.
Backu# can be either user mana%ed <co#yin% files with OS commands= or ser$er
mana%ed <36A( - 3eco$ery 6ana%er based=. 2f you use 36A(& you can ha$e
incremental backu#s <i.e. backin% u# only chan%ed blocks since last backu#=.
36A( is not discussed in this book.
2.2 Backup and reco0ery in no arc(i0e log mode
?hen the database is runnin% in no archi$e lo% mode& only cold back u# can be
taken. "he ste#s are -
. Shutdown the database
). Co#y data files& control files& redo lo% files usin% OS commands to a
backu# location.
8. Startu# database
2f any of the files <dataCcontrolCredo= is corru#t in no archi$e lo% mode& you
need to restore all files from backu#. 2f relocation of files is necessary& you need
to o#en the database in mount sta%e and issue rename command to s#ecify new
location of the files. "hen you should o#en database for normal use. 2n no
archi$e lo% mode& you can only reco$er data& which was taken durin% back u#
#eriod. E$en if only one file is corru#t& you need to restore all files and reco$er
entire database.
2.3 Backup in arc(i0e log mode
2n archi$e lo% mode& backu# can be taken while database is runnin%.
- 8) -
Oracle DBA Concise Handbook
"o take backu# of data file& follow these ste#s -
. A/"E3 "AB/ESPACE name BE12( BAC94P
). 4se OS commands to co#y data file
8. A/"E3 "AB/ESPACE name E(D BAC94P
Data file headers donJt %et u#dated until backu# ends. 2deally& #erform hot
backu# when there is less D6/ is occurrin% in the database.
2.4 /ser managed complete reco0ery
2n all the followin% cases& it is assumed that database is runnin% in archi$e lo%
mode and backu# was already taken.
2.*.1 S+ste, table space lost<corrupt
. S"A3"4P 6O4("
). 3estore only system table s#ace file
8. 2f re'uired& relocate file - A/"E3 DA"ABASE 3E(A6E file "O new
file
+. 3ECOBE3 A4"O6A"2C DA"ABASE <or DA"A;2/E file name=
:. A/"E3 DA"ABASE OPE(
2.*.2 .on>s+ste, table space lost<corrupt
. S"A3"4P 6O4("
). 6ake data file offline - A/"E3 DA"ABASE file name O;;/2(E
8. A/"E3 DA"ABASE OPE(
+. 3estore data file from backu# to database location
:. 2f re'uired& relocate file - A/"E3 "AB/ESPACE table s#ace name
O;;/2(E 266ED2A"E for issuin% check #oint
>. 3ECOBE3 A4"O6A"2C "AB/ESPACE table s#ace name
5. A/"E3 "AB/ESPACE table s#ace name O(/2(E
2.*.3 .on>s+ste, table space lost<corrupt when no bac&up ta&en
. S"A3"4P 6O4("
). A/"E3 DA"ABASE C3EA"E DA"A;2/E filename with #ath AS new
filename <only if relocate=
- 88 -
Oracle DBA Concise Handbook
8. 3ECOBE3 DA"ABASE <DA"A;2/E filename=
+. A/"E3 DA"ABASE OPE(
2.*.* Instance 9ailed durin# bac&up
Entire database wonJt start. Data file header freeLes durin% backu#& so no
check#oint information is written.
. S"A3"4P 6O4("
). A/"E3 DA"ABASE E(D BAC94P
8. A/"E3 DA"ABASE OPE(
2.5 /ser managed incomplete reco0ery
2./.1 )i,e<%ancel<%han#e (S%.! based
. S"A3"4P 6O4("
). 3estore all data files <includin% system& data& indeM& undo but not control
file or redo lo% files=
8. 3ECOBE3 DA"ABASE 4("2/ "26E Xdd-mon-yyyy hh)+QmiQssJ <or
CA(CE/ or CHA(1E number=
+. A/"E3 DA"ABASE OPE( 3ESE"/O1S
/o% se'uence number will be re-initialiLed.
SH4"DO?(
"ake full backu# of database
2." Logical backup 1 e.port2import and 3ata 4ump
EM#ort may be either throu%h con$entional #ath or direct #ath. 2n direct #ath
eM#ort& the e$aluatin% buffer is by#assed and makes it faster.
6ost common eM#ort command is <from OS command #rom#t= -
EAP XsysC#asswordWmydb as sysdbaJ
6ost common #arameters are -
;2/E - out#ut file <default eM#dat.dm#=
D23EC" - direct #ath <(=
O?(E3 - list of ownersCusers
- 8+ -
Oracle DBA Concise Handbook
"AB/ES - list of table names
PA3;2/E - #arameter file name <in this file you can store all o#tions=
"AB/ESPACES - list of table s#aces to eM#ort
"3A(SPO3"F"AB/ESPACE - eM#ort trans#ortable table s#ace metadata <(=
Similarly& im#ort is run as -
26P XsysC#asswordWmydb as sysdbaJ
;2/E - in#ut file <eM#dat.dm#=
21(O3E - i%nore create obIect errors <(=
3O?S - im#ort data rows <7=
EMam#le of eM#ort&
eM# systemC(ass'ord fileP;QRDatabaseReM#Fmkm.dm# ownerPmkm rowsPy
7ou can run eM#ortCim#ort in interacti$e mode i.e. it will ask you about
#arameters durin% runtime.
Data 6786
;rom *% onward& Oracle introduces new utilities EAPDP and 26PDP <as run
from OS command #rom#t= to fast data loadin% <eM#ortCim#ort=. As it uses AP2&
it is si%nificantly faster than eM#ortCim#ort utility. 7ou can e$en monitor data
#um# #ro%ress from data dictionary $iews.
Data #um# is run as - 26PDP userC#assword D23EC"O37PdataF#um#Fdir
D46P;2/EPd#dum#.dm# 0OBF(A6EPmyFim#ort
?here& D23EC"O37 is an eMternal directory name already created. EAPDP
has similar syntaM.
Oracle automatically creates dataF#um#Fdir in NO3AC/EFHO6EC adminC
databaseFnameC d#dum#. Howe$er if you want you can create a directory of
your own like this -
create irector! ata_p"mp_ir as
#C$%Oracle11g%amin%MYDB%p"mp#&
7ou can $iew location of directory by
select ' (rom ba_irectories )here D*+,CTO+Y_N-M, . #D-T-_/0M/_D*+#
EMam#leQ
e1pp s!stem2pass)or D*+,CTO+Y.ata_p"mp_ir
D0M/3*L,.s"permar4et5mp SC6,M-S.m4m
- 8: -
Oracle DBA Concise Handbook
Oracle now ad$ises use of data #um# o$er eM#ortCim#ort.
2.% &5L Loader
4sin% SD/ /oader& you can load data from teMt file to Oracle tables.
"he com#onents you need to run SD/ /oader are -
. Control file - s#ecifies how to load data in Oracle
). Data file - the data in teMt file which will be loaded
8. Discard file - data that is discarded by SD/ /oader because of not
matchin% load condition
+. Bad file - data that SD/ /oader could not load because of error
:. /o% file - syno#sis of loadin% o#eration
2f you s#ecify D23EC"P7 o#tion& SD/ /oader will by#ass buffer and sa$e data
directly into data blocks in the disk. 2t makes data loadin% $ery fast howe$er&
this o#tion does not enforce constraints& does not fire insert tri%%ers& does not
allow SD/ functions in control file and locks entire table durin% loadin%.
7ou can run SD/ /oader from OS command #rom#t as -
S7LLD+ "ser2pass)or8b CONT+OL.m!(ile5ctl
A sam#le control file is shown below <assumin% in#ut data file is ] delimited=.
LO-D D-T-
*N3*L, #3$%D0M/%C0STOM,+5T9T#
B-D3*L, #3$%D0M/%C0STOM,+5B-D#
D*SC-+D3*L, #3$%D0M/%C0STOM,+5DSC#
-//,ND
*NTO T-BL, C0STOM,+
3*,LDS T,+M*N-T,D BY :;:
T+-*L*N< N0LLCOLS
=
C0STNO D,C*M-L ,9T,+N-L :s>_c"st_no5ne1tval:?
C0STN-M, C6-+?
S,9 C6-+?
-DD+,SS C6-+?
C*TY C6-+?
ST-T, C6-+?
CO0NT+Y C6-+?
/OSTCOD, C6-+?
/6ON, C6-+?
,M-*L C6-+?
NOT, C6-+?
D-T,ST-M/ D-T, :YYYY@MM@DD 66AB$M*$SSC
D
- 8> -
Oracle DBA Concise Handbook
(ote for (46BE3 columns you s#ecify DEC26A/ EA"E3(A/ and for
BA3CHA3) columns you s#ecify CHA3 in SD/ /oader control file.
2.' 6et$orking *undamentals
Oracle (et is an internal layer which mana%es communication between client
and ser$er. 2t is confi%ured on ser$er& client& web ser$er etc.
2.3.1 %on9i#urin# Oracle .et on server
/istener is a ser$er-side networkin% com#onent& which listens for re'uests from
client on ser$er. "o communicate with Oracle ser$er& /istener ser$ice must be
started on ser$er. /istener is confi%ured in ser$er usin% listener.ora file.
;ollowin% is a sam#le listener.ora file.
E L*ST,N,+5O+- Net)or4 Con(ig"ration 3ile$
,$%oracle%oraFA%net)or4%amin%listener5ora
E <enerate b! Oracle con(ig"ration tools5
L*ST,N,+ .
=D,SC+*/T*ON_L*ST .
=D,SC+*/T*ON .
=-DD+,SS_L*ST .
=-DD+,SS . =/+OTOCOL . */CD=G,Y . ,9T/+OCHDD
D
=-DD+,SS_L*ST .
=-DD+,SS . =/+OTOCOL . TC/D=6OST . enselD=/O+T .
1IA1DD
D
D
D
S*D_L*ST_L*ST,N,+ .
=S*D_L*ST .
=S*D_D,SC .
=<LOB-L_DBN-M, . MDBD
=O+-CL,_6OM, . ,$%oracle%oraFAD
=S*D_N-M, . MDBD
D
D
7ou can mana%e listener from OS command #rom#t usin% /S(3C"/ utility.
- 85 -
Oracle DBA Concise Handbook
Oracle (et 6ana%er is a tool usin% which you can mana%e most clientCser$er
confi%uration files.
2.3.2 %on9i#urin# Oracle .et on client
4sually you connect to Oracle ser$er from client as 4SE3CPASS?O3DWDB
<this is known as connect descri#tor=.
How the database name you s#ecified in connection is resol$ed to eMact
database in the ser$er is known as name resolution method.
6ost #o#ular name resolution methods are - host namin%& local namin% <most
common usin% tnsnames.ora= and Oracle 2nternet Directory namin%.
2n tnsnames.ora file <usually in client machine it resides in NO3AC/EFHO6E C
networkCadmin folder=. A sam#le tnsnames.ora file is shown below.
E TNSN-M,S5O+- Net)or4 Con(ig"ration 3ile$
,$%oracle%oraFA%net)or4%amin%tnsnames5ora
E <enerate b! Oracle con(ig"ration tools5
MDB .
=D,SC+*/T*ON .
=-DD+,SS_L*ST .
=-DD+,SS . =/+OTOCOL . TC/D=6OST . enselD=/O+T . 1IA1DD
D
=CONN,CT_D-T- .
=S,+V,+ . D,D*C-T,DD
=S,+V*C,_N-M, . MDBD
D
D
M-+G,T .
=D,SC+*/T*ON .
=-DD+,SS_L*ST .
=-DD+,SS . =/+OTOCOL . TC/D=6OST . 1HF51AI5AIJ5AIHD=/O+T
. 1IA1DD
D
=CONN,CT_D-T- .
=S,+V,+ . D,D*C-T,DD
=S,+V*C,_N-M, . M-+G,TD
D
D
6ost common connection #roblem is UO3A-):+ "(S could not resol$e
ser$ice nameV. ?hen this occurs& check the client is lookin% at correct
- 8@ -
Oracle DBA Concise Handbook
tnsnames.ora file <there may be multi#le $ersion in com#uter=. 7ou can $erify
this by checkin% "(SFAD62( en$ironment $ariable. Also check whether
client com#uter can talk to ser$er com#uter by runnin% U"(SP2(1 ser$er i#
addressV command. Or you can use P2(1 S2D command as well.
Check s'lnet.ora file and see whether it s#ecifies local namin% first. "his file
resides in both client and ser$er.
Sam#le of what an s'lnet.ora file will contain.
(A6ES.D23EC"O37FPA"HP <"(S(A6ES& O(A6ES& HOS"(A6E=
2.) Log Miner
4sin% lo% miner& you can eMamine redo lo% filesK
2.4.1 $unnin# lo# ,iner
S#ecify a directory by 0TL_3*L,_D*+.,$%O+-CL,%O+-D-T-%0NLO-D
#arameter and bounce database.
Create a dictionary file
,9,C0T, DBMS_LO<MN+_D5B0*LD
=#ictionar!5ora#?#,$%O+-CL,%O+-D-T-%0NLO-D#? O/T*ONS .K
DBMS_LO<MN+_D5STO+,_*N_3L-T_3*L,D&
Add lo% files
e1ec bms_logmnr5a_log(ile =#,$%oracle%oraata%MDB%-rchive1%
-+CHHHAL5HH1#? bms_logmnr5ne)D&
e1ec bms_logmnr5a_log(ile =#,$%oracle%oraata%MDB%-rchive1%
-+CHHHAJ5HH1#? bms_logmnr5a(ileD&
e1ec bms_logmnr5a_log(ile =#,$%oracle%oraata%MDB%-rchive1%
-+CHHHAM5HH1#? bms_logmnr5a(ileD&
e1ec bms_logmnr5a_log(ile =#,$%oracle%oraata%MDB%-rchive1%
-+CHHHAF5HH1#? bms_logmnr5a(ileD&
Start lo% miner session
e1ec bms_logmnr5start_logmnr =ict(ilename.K
#,$%O+-CL,%O+-D-T-%0NLO-D%ictionar!5ora#D&
Once the redo lo%s were analyLed& all the DD/ <and some D6/= statements
a##lied in the source database will be found in the BN/O16(3FCO("E("S
- 8, -
Oracle DBA Concise Handbook
$iew. 2m#ortant columns of this $iew are - SD/F4(DO& SD/F3EDO&
4SE3(A6E& SC(& "26ES"A6P& CO662"F"26ES"A6P& "AB/ESPACE&
SE1F(A6E& SE1F"7PE& and OPE3A"2O(.
"he /o% 6iner session is closed by eMecutin% followin% command in the same
session.
,9,C DBMS_LO<MN+5,ND_LO<MN+
After the session is com#lete& all data in the $Nlo%mnrFcontents table are
deleted. Be sure to eMecute C3EA"E "AB/E myFlo%mnr AS SE/EC" ... to
co#y the data before analyLin% the contents.
2.4.2 ?ilterin# data that is returned
/o% 6iner can #otentially be dealin% with lar%e amounts of information. "here
are se$eral methods you can use to limit the information that is returned to the
BN/O16(3FCO("E("S $iew& as well as the s#eed at which it is returned.
"hese o#tions are s#ecified when you start /o%6iner.
Showin% Only Committed "ransactions
At the time of startin%
,9,C0T, DBMS_LO<MN+5ST-+T_LO<MN+=O/T*ONS .K
DBMS_LO<MN+5COMM*TT,D_D-T-_ONLYD&
;ilterin% Data By "ime
,9,C0T, DBMS_LO<MN+5ST-+T_LO<MN+=D*CT3*L,N-M, .K
#2oracle2ictionar!5ora#? ST-+TT*M, .K TO_D-T,=#H1@Nan@AHHB
HM$OH$HH#? #DD@MON@YYYY 66$M*$SS#D? ,NDT*M, .K TO_D-T,=#H1@
Nan@AHHB HM$BI$HH#? #DD@MON@YYYY 66$M*$SS#DD&
;ilterin% Data By SC(
,9,C0T, DBMS_LO<MN+5ST-+T_LO<MN+=D*CT3*L,N-M, .K
#2oracle2ictionar!5ora#? ST-+TSCN .K 1HH? ,NDSCN .K 1IHD&
2.4.3 7uer+in# on lo# ,iner
Some eMam#les are shown below.
S,L,CT 0S,+N-M,? S7L_+,DO 3+OM VPLO<MN+_CONT,NTS
- +* -
Oracle DBA Concise Handbook
W6,+, 0S,+N-M, QK #SYS#&
S,L,CT O/,+-T*ON? S7L_+,DO? S7L_0NDO 3+OM VPLO<MN+_CONT,NTS
W6,+, S,<_OWN,+ . #MGM# -ND S,<_N-M, . #/+OD0CT# -ND O/,+-T*ON
. #*NS,+T# -ND 0S,+N-M, . #MGM#&
2.4.* "o# ,iner related data dictionar+ views
BN/O16(3FCO("E("S - Shows chan%es made to user and table
information.
BN/O16(3FD2C"2O(A37 - Shows information about the /o% 6iner
dictionary file& #ro$ided the dictionary was created usin% the
S"O3EF2(F;/A"F;2/E o#tion.
BN/O16(3F/O1S - Shows information about s#ecified redo lo%s. "here is
one row for each redo lo%.
BN/O16(3FPA3A6E"E3S - Shows information about o#tional /o% 6iner
#arameters& includin% startin% and endin% system chan%e numbers <SC(s= and
startin% and endin% times.
- + -
Oracle DBA Concise Handbook
2.1+ ,eal 7pplication #lusters ,7#!
An 3AC database is a clustered database. 2n 3AC en$ironment& multi#le Oracle
instances <which are connected $ia interconnect= o#erate on same database files
on disk. Different ser$ers must access set of shared disks and should
communicate throu%h hi%h-s#eed interconnection. Chan%ed database blocks and
lo% information on one instance can be mo$ed to another instance throu%h
memory interconnection without writin% on disk. "his is known as cac)e fusion
<see later=. "he main ad$anta%e of 3AC is scalability and hi%h a$ailability.
Se$eral ser$ers with Oracle instances can be added to system. 2f one of them
fails& others continue to work without affectin% o#erations. ;or this reason 3AC
is also known as Hi%h A$ailability. ?hen work load %rows& you can sim#ly add
another ser$er to the %rid <3AC is a ty#e of %rid com#utin% after all=.
"he data files are stored in se$eral disk dri$es which are connected by cluster
a'are stora*e. By addin% multi#le instances& we can add and remo$e and sin%le
Oracle instance without brin%in% the database down. So& database always
remains a$ailable. "hat is the essence of 3AC - hi%h a$ailability.
An 3AC database is mana%ed by Oracle &luster'are. 3AC o#erates in s)ared
e+eryt)in* architecture mode.
Any stora%e <e%. SA(& SCS2 etc.= can be used with 3AC. Howe$er& %ood 2CO
s#eed is re'uired for scalability of data $olume.
3AC su##orts u# to ** clusters which may be different at hardware le$el but
must run same o#eratin% system.
Oracle recommends usin% AS6 <Automatic Stora%e 6ana%ement= for ease of
dealin% with clustered stora%e.
An Oracle 3AC database re'uires three com#onents - cluster nodes <the ser$ers
or com#uters runnin% Oracle instances=& shared stora%e <disk dri$es= and Oracle
Clusterware <software a##lication=.
Installing RAC
"he first ste# of workin% with 3AC is to install ^Oracle Clusterware^ which is
installed $ia 4ni$ersal 2nstaller.
"hen you ha$e to confi%ure the clusterware.
- +) -
Oracle DBA Concise Handbook
"hen install AS6 <Automatic Stora%e 6ana%ement=.
(ow install Oracle % database.
"hen #erform #ost installation tasks. "his ensures that clusterware and database
are installed #ro#erly and they are aware of each other.
2t is #ossible to con$ert your normal sin%le instance Oracle database to an 3AC
database. 7ou can achie$e this $ia Enter#rise 6ana%er or rconfi* utility.
Administering Clusterware
Oracle Clusterware includes two im#ortant com#onentsQ the $otin% disk and the
OC3. "he $otin% disk is a file that mana%es information about node
membershi#& and the OC3 is a file that mana%es cluster and Oracle 3AC
database confi%uration information.
3AC can be administered $ia Oracle Enter#rise mana%er. On E6Gs web console
mode& click on A$ailability tab to see details of Clusterware. 7ou can click on
"o#olo%y tab to see a $isual re#resentation of your nodes. "he 2nterconnect tab
shows you info on interfaces. 7ou can also add new instance to clusterware $ia
E6 <under Ser$er tab=.
Oracle Clusterware #osts alert messa%es in alert lo% - which is under
NC3SFhome. 3AC data dictionary $iews are created by catclust.s'l.
Cache Fusion
Oracle 3AC uses &ac)e ,usion to synchroniLe the data stored in the buffer
cache of each database instance - i.e. to kee# track of which nodes are writin%
to which blocks and to ensure that two nodes do not u#date du#licate co#ies of
the same block. Since all com#utersCinstances in an 3AC access the same
database& the o$erall system must %uarantee the coordination of data chan%es on
different com#uters such that whene$er a com#uter 'ueries data it recei$es the
current $ersion - e$en if another com#uter recently modified that data. Oracle
3AC refers to this functionality as Cache ;usion. 2t in$ol$es the ability of 3AC
to fuse in-memory data cached #hysically se#arately on each com#uter into a
sin%le %lobal cache. "his sa$es a lot of resource time.
- +8 -
Oracle DBA Concise Handbook
2.11 &tandby database also Oracle 3ata 8uard!
Stand by database is used as a #rotection a%ainst failure of main #roduction
database.
2.11.1 (h+sical stand b+
"his may be created from last back u# taken for the #roduction database and
there after a##lyin% archi$ed redo lo% files on it. "his is similar to reco$erin% a
database. Howe$er& for stand by database& this reco$ery is like a continuous
#rocess& because& archi$ed lo%s <from #roduction database= are continuously
bein% a##lied on it to make it sync with #roduction database. Howe$er& stand by
database wonJt be a$ailable for use until reco$ery is com#leted.
2.11.2 "o#ical stand b+
2nstead of a##lyin% archi$ed redo lo% files& SD/ statement is constructed from
lo% files are bein% a##lied to stand by database <similar to /o% 6iner method=.
"he database is a$ailable for use durin% a##lication of SD/s.
2.12 ,eplication
2t allows you to ha$e multi#le co#ies of same database at different locations. At
most basic le$el& re#lication is im#lemented usin% materialiLed $iews. 2n case of
synchronous re#lication& transactions are either successfully #ro#a%ated to all
sites or it is rolled back. 2t ensures no conflict will occur between sites. 2t
re'uires stable network en$ironment and mostly used for read only materialiLed
$iews. 2n asynchronous re#lication& chan%es to each site is stored locally and
forwarded to other sites. 2n this case& conflict resolution #rocesses are re'uired.
3e#lication %enerally im#ro$es #erformance across network. ;or eMam#le& if
you use a database for online transactions as well as re#ortin%& you can re#licate
the database and run transactions and re#ortin% on different $ersions.
- ++ -
Oracle DBA Concise Handbook
3 (er9or,ance )unin#
3.1 -uning de0elopment and production systems
OracleJs to# down a##roach for de$elo#ment systems
. "une data desi%n
). "une a##lication desi%n
8. "une memory allocation
+. "une 2CO and #hysical structures
:. "une resource contention
>. "une for underlyin% #latform <OS=
OracleJs #roduction #erformance tunin% #rinci#les
. Define #roblem clearly and formulate a tunin% %oal
). EMamine host system and %ather statistics
8. Com#are common #roblems with OracleJs documentation
+. 1et a conce#tual #icture of what went wron% from %athers statistics
:. 2dentify chan%es to be done and im#lement those chan%es
>. Check whether tunin% obIecti$e has been met or not& re#eat ste#s until
tunin% is com#lete.
3.2 &ources o* tuning in*ormation
3.2.1 Alert lo# 9ile
"his file records information and error messa%es for $arious database acti$ities.
"his file is located at BAC913O4(DFD46PFDES" folder. "he name format
is alertFS2D.lo%.
3.2.2 )race 9iles
Back%round #rocess trace files contains session information for #rocess that
created them. "hese files are a$ailable in BAC913O4(DFD46PFDES"
folder. (ame format for the trace file is usually S2DFP3OCESSFnnnn.trc e.%.
mdbFl%wrF:,@.trc.
4ser trace files are found in 4SE3FD46PFDES" folder. "hese are created
when error occurs in userJs ser$er #rocess. 4ser tracin% can be enabled usin%
- +: -
Oracle DBA Concise Handbook
A/"E3 SESS2O( SE" SD/F"3ACE P "34E command or by eMecutin%
#acka%e as
EAEC
S7S.DB6SFS7S"E6.SE"FSD/F"3AC"F2(FSESS2O(
<sid& serial_& "34E=
3.2.3 =iews co,,onl+ used in tunin#
BNS1AS"A"
BNEBE("F(A6E
BNS7S"E6FEBE("
BNSESS2O(FEBE("
BNSESS2O(F?A2"
BNS"A"(A6E
BNS7SS"A"
BNSESS"A"
BNSESS2O(
BN?A2"S"A"
DBAF"AB/ES
DBAF2(DEAES
DBAFS"A"S
DBAFDA"AF;2/ES
DBAFSE16E("S
DBAFH2S"O13A6S
3.3 #ollecting statistics
3un 4"/BS"A" and 4"/ES"A" to collect all database acti$ities in the %i$en
time #eriod in a sin%le file.
3un from NO3AC/EFHO6ECrdbmsCadminCutlbstat.s'l and utlestat.s'l
"he resultin% file is named as 3EPO3"."A"
3.3.1 Statspac&
3un s#create.s'l scri#t from NO3AC/EFHO6ECrdbmsCadmin folder.
2t will create PE3;S"A" schema with all re'uired obIects.
"o collect statistics& use EAEC4"E S"A"SPAC9.S(AP #rocedure <as
PE3;S"A" user=. A sna#shot of statistics will be collected and stored in
PE3;S"A" schema tables.
- +> -
Oracle DBA Concise Handbook
4se NO3AC/EFHO6ECrdbmsCadminCs#auto.s'l to run automatic
statistics collection at s#ecific inter$als.
Once you %athered enou%h statistics& you can %enerate a re#ort usin%
NO3AC/EFHO6ECrdbmsCadminCs#re#ort.s'l scri#t.
3.4 Oracle supplied 8/I tuning tools
Ca#acity Planner
Performance 6ana%er - obser$e database #erformance.
"o# Sessions - see which users are consumin% most resource
"race Data Biewer
/ock 6onitor
"o# SD/ - most resource consumin% SD/s
Performance O$er$iew - see current #erformance of database
Oracle EM#ert - %athers statistics and %i$es recommendations for tunin%
2ndeM "unin% ?iLard - identify unused indeMes
3.5 &5L application tuning and design
3./.1 )'($O?
2t is used to format user trace files. 4sa%e eMam#le is <from OS command
#rom#t= - "9P3O; O3AF)8+."3C "3ACE."A"
Some of its #arameters are -
EAP/A2( - %enerates eM#lain #lan for each statement in trace file
S7S - out#ut file includes recursi$e SD/ statements <i.e. those in$ol$in% data
dictionary 'ueries=
3ECO3D - s#ecifies a file where SD/ statements of trace file are written
EMam#le usa%e
"9P3O; O3AF)8+."3C "3ACE."A" S7SP(O
EAP/A2(P696C696W6DB 3ECO3DPSD/."A"
"o identify SD/ statements& which may re'uire tunin%& look for statements -
Consumin% eMcess CP4 resource
"akin% lon% time to #arse& eMecute and fetch
3eadin% too many data blocks from disk and too few from S1A
Access many data blocks but return only few rows
3./.2 28plain plan
- +5 -
Oracle DBA Concise Handbook
Create #lan table usin% NO3AC/EFHO6ECrdbmsCadminCutlM#lan.s'l
Po#ulate P/A(F"AB/E usin% EAP/A2( P/A( ;O3\ command. ;or
eMam#le&
,9/L-*N /L-N
S,T ST-T,M,NT_*D . #/+*C,#
3O+
S,L,CT /5/+ODCOD,? /5/+ODN-M,? N5S,LL/+*C,? M5M3DN-M,?
NVL=S0M=*57TY-V-*L-BL,D?HD :-LL STO+,S 7TY:
3+OM /+OD0CT /
NO*N /+*C, N ON =/5/+ODCOD, . N5/+ODCOD,D
L,3T NO*N M-N03-CT0+,+ M ON =/5M3DBY . M5M3DNOD
L,3T NO*N *NV,NTO+Y * ON =/5/+ODCOD, . *5/+ODCOD,D
W6,+, SYSD-T, B,TW,,N N5ST-+TD-T, -ND N5,NDD-T,
-ND /56-SS,+*-LNO.H
<+O0/ BY /5/+ODCOD,? /5/+ODN-M,? N5S,LL/+*C,? M5M3DN-M,
"o $iew the #lan& you may issue followin% statement
S,L,CT L/-D=# #?B'=L,V,L@ADD ;; O/,+-T*ON ;; # # ;;
O/T*ONS ;; # # ;;
OBN,CT_N-M, :,9,C0T*ON_/L-N:? *O_COST?
C/0_COST?T,M/_S/-C,
3+OM /L-N_T-BL,
ST-+T W*T6 *D . H CONN,CT BY /+*O+ *D . /-+,NT_*D
3emember that& if you run the abo$e 'uery& you will see the #lan in an
indented $iew. "he innermost o#erations are eMecuted first. 2f two
o#erations a##ear at same le$el <with same inner le$el=& the to# one is
eMecuted first.
3./.3 Auto trace
4nlike eM#lain #lan& auto trace eMecutes the actual SD/ statement before
%eneratin% the #lan.
7ou need to create P/4S"3ACE role by runnin% #lustrce.s'l as S7S user.
"hen you need to assi%n P/4S"3ACE role to users who will use auto trace.
"hey also need P/A(F"AB/E in their schemas.
"o use auto trace& issue followin% command from SD/ Plus.
SE" A4"O"3ACE O(
"hen issue any SD/ statement and you will always see statistics after result is
dis#layed.
- +@ -
Oracle DBA Concise Handbook
3." Optimi9er
Earlier $ersions of Oracle used 3ule Base O#timiLer <3BO=. But latest $ersions
use Cost Based O#timiLer <CBO= by default.
Statistics must be %athered to benefit from CBO.
3.0.1 Gatherin# statistics
A/"E3 2(DEA indeMFname CO6P4"E S"A"2S"2CS
A/"E3 "AB/E tableFname CO6P4"E S"A"2S"2CS
A/"E3 "AB/E tableFname ES"26A"E S"A"2S"2CS ;O3
"AB/ESCCO/46(S col& col)CA// CO/46(SCA// 2(DEAES
EAEC4"E DB6SF4"2/2"7.A(A/7EEFSCHE6A<G696G&GCO6P4"EG=
Oracle now recommends that you use DB6SFS"A"S #acka%e instead of
AnalyLe.
EAEC DB6SFS"A"S.%atherFschemaFstats <ownname PT X696J& cascade
PTtrue& estimateF#ercent PT dbmsFstats.autoFsam#leFsiLe=
3.0.2 Opti,i;er ,odes
2n initialiLation file& you can set o#timiLer mode as shown below
OP"262EE3F6ODEPCHOOSE <this is default= or ;23S"F3O?S or
A//F3O?S or 34/E or ;23S"F3O?SFn where n P C*C**C***.
7ou can also chan%e o#timiLer mode at session le$el.
A/"E3 S7S"E6 SE" OP"262EE3F6ODEPCHOOSE
"o chan%e o#timiLer mode at statement le$el& you should use hints usin% C[Z \
[C.
SE/EC" C[Z 34/E [C \
Commonly used hints are - ;4//& 2(DEA& 3E?32"E& and PA3A//E/ etc.
2f statistics eMists for any one table or indeM in$ol$ed in SD/ statement& CBO is
used& otherwise 3BO is used.
- +, -
Oracle DBA Concise Handbook
"o reuse a sa$ed eMecution #lan& you can use U#lan stabilityV <in the form of
stored outline= feature or UmaterialiLed $iewV.
3.0.3 -ateriali;ed view
4nlike in normal $iew& materialiLed $iew actually stores the data in tables.
"o create materialiLed $iew& issue
C+,-T, M-T,+*-L*R,D V*,W schema5mvie)_name
B0*LD *MM,D*-T,
+,3+,S6 ON D,M-ND =or +,3+,S6 COM/L,T, ON COMM*TD
,N-BL, 70,+Y +,W+*T,
-S
S,L,CT >"er!&
,9,C DBMS_MV*,W5+,3+,S6=#schema5mvie)_name#?#C#D&
,9,C DBMS_MV*,W5+,3+,S6_-LL_D,/,ND,NT=#table_name#D&
,9,C DBMS_MV*,W5+,3,+S6_-LL_MV*,WS&
3.0.* (artitioned tables
+.6./.1 Range 6artition
2t uses ran%e of column $alues to determine where the record will be inserted.
C3EA"E "AB/E student <\= PA3"2"2O( B7 3A(1E <%raduationFyear=
<PA3"2"2O( #F)*** BA/4ES /ESS "HA( )*** "AB/ESPACE studentF&
PA3"2"2O( #F)**) BA/4ES /ESS "HA( )**) "AB/ESPACE studentF)&
PA3"2"2O( #F)**+ BA/4ES /ESS "HA( )**+ "AB/ESPACE studentF8&
PA3"2"2O( #Ferror BA/4ES /ESS "HA( <6AABA/4E= "AB/ESPACE
studentF+=O
+.6./.' ist 6artition
2t is based on set of s#ecified $alue instead of ran%e of $alues.
C3EA"E "AB/E student <\= PA3"2"2O( B7 /2S" <de%ree=
<PA3"2"2O( #Fen%% BA/4ES <XB"echJ&J6"echJ= "AB/ESPACE stuFen%%&
PA3"2"2O( #Fcomm BA/4ES <X6comJ&JBcomJ= "AB/ESPACE stuFcomm&
PA3"2"2O( #Farts BA/4ES <X6AJ&JBAJ= "AB/ESPACE stuFarts=O
- :* -
Oracle DBA Concise Handbook
+.6./.+ Has9 6artition
2t uses a hashin% al%orithm to assi%n records in #articular #artition. 2t usually
kee#s almost e'ual number of records in each #artition.
C3EA"E "AB/E student <\= PA3"2"2O( B7 HASH <rollFno=
PA3"2"2O(S 8 S"O3E 2( <stuF& stuF)& stuF8=O
+.6././ Co86osite 6artition
2t uses ran%e #artition and inside it uses hash sub-#artitions. Data is #hysically
stored in sub-#artition le$el.
C3EA"E "AB/E student <\=
PA3"2"2O( B7 3A(1E <%raduationFyear=
S4BPA3"2"2O( B7 HASH <rollFno= S4BPA3"2"2O(S 8
S"O3E 2( <stuF& stuF)& stuF8=
<PA3"2"2O( #F)*** BA/4ES /ESS "HA( )***&
PA3"2"2O( #F)**) BA/4ES /ESS "HA( )**)&
PA3"2"2O( #F)**+ BA/4ES /ESS "HA( )**+&
PA3"2"2O( #Ferror BA/4ES /ESS "HA( <6AABA/4E==O
(oteQ Any bitma# indeMes created on #artitioned table must be local <to the
#artition=.
+.6./.0 Cl7ster
A cluster is a %rou# of one or more tables whose data is stored at same #lace
<#hysically=. "his hel#s faster access of data columns& which are often 'ueried
as Ioins because Oracle ser$er needs to read less number of #hysical data
blocks.
C3EA"E C/4S"E3 de#tFem#
<dno (46BE3= S2EE *** "AB/ESPACE clst
C3EA"E 2(DEA de#tFem#FidM
O( C/4S"E3 de#tFem# "AB/ESPACE idM
C3EA"E "AB/E de#t <dno (46BE3& dname BA3CHA3)<**==
C/4S"E3 de#tFem#<dno=O
C3EA"E "AB/E em# <eno (46BE3& ename BA3CHA3)<**=& dno
(46BE3= C/4S"E3 de#tFem#<dno=O
- : -
Oracle DBA Concise Handbook
Oracle % allows reference #artition and inter$al #artition.
"ake an eMam#le of "ransaction and "ransaction Detail tables. "hese two are
linked by forei%n key "rans2d. (ow& master table has transaction date but detail
table do not. ?e want both tables be #artitioned by transaction date. 2n %& we
can s#ecify details tables be #artitioned based on forei%n key reference "rans2d.
2nter$al #artition is useful when we do not know how many #artitions we need
beforehand. 2n abo$e eMam#le& we can s#ecify the table such a way whene$er
new month be%ins& a new #artition will be created automatically.
3.% -uning s(ared pool
Shared #ool consists of library cache and data dictionary cache. /ibrary cache
caches most recently used SD/ and P/CSD/ statements. Data dictionary cache
caches data dictionary information. Shared #ool is mana%ed by a /east 3ecently
4sed al%orithm.
;indin% a matchin% SD/ statement in shared #ool is known as cache hit. ;or
cache hit to occur& two SD/ statements must be eMactly same i.e. their ASC22
$alue e'ui$alent should be same. "he aim of tunin% shared #ool is to maMimiLe
cache hit ratio.
3.1.1 -easurin# shared pool per9or,ance
Hi%h cache hit ratio indicates that your a##lication users are %ettin% results of
SD/ and P/CSD/ mostly from memory rather than readin% from disk.
S,L,CT ' 3+OM VPL*B+-+YC-C6,
"he $alue in 1E"H2"3A"2O column for SD/ A3EA& "AB/ECP3OCED43E&
BOD7 and "3211E3 rows should be $ery close to i.e. **Y.
Similarly P2(H2"3A"2O should also be $ery close to .
1E" is referred to #arse lock& while P2( is referred to eMecution time locks.
A well-tuned O/"P system should ha$e 1E"H2"3A"2O and P2(H2"3A"2O
,*Y or hi%her for SD/ A3EA.
Data dictionary #erformance is measured by
- :) -
Oracle DBA Concise Handbook
S,L,CT 1@=S0M=<,TM*SS,SD2S0M=<,TSDD SData ictionar! hit
ratioC 3+OM VP+OWC-C6,
"his $alue should be o$er *.@: for O/"P systems.
3.1.2 I,provin# shared pool per9or,ance
+.&.'.1 Add 8ore 8e8or: to s9ared 6ool
"he siLe of shared #ool is determined by SHA3EDFPOO/FS2EE initialiLation
#arameter.
S,L,CT /OOL? S0M=BYT,SD :S*R,: 3+OM VPS<-ST-T W6,+, /OOL .
#share pool# <+O0/ BY /OOL
4se followin% command to chan%e shared #ool siLe
-LT,+ SYST,M S,T S6-+,D_/OOL_S*R,.AHHM
+.&.'.' -ake s6ace ;or large )2"1 state8ents
7ou can set aside a reser$ed area in S1A for lar%e P/CSD/ #acka%es. "his area
is controlled by SHA3EDFPOO/F3ESE3BEDFS2EE #arameter.
Determine which #acka%es are loaded into memory from followin% command
S,L,CT ' 3+OM VPDB_OBN,CT_C-C6, W6,+, TY/, *N =#/-CG-<,#?
#/-CG-<, BODY#D
+.&.'.+ (ee6 i86ortant )2"1 code in 8e8or:
7ou can U#inV most fre'uently used P/CSD/ code in memory. "o do this -
. Build DB6SFSHA3EDFPOO/ #acka%e by runnin%
NO3AC/EFHO6E CrdbmsCadminCdbms#ool.s'l scri#t.
). /oad a #acka%e usin% EAEC4"E
DB6SFSHA3EDFPOO/.9EEP<XPAC9A1EF(A6EJ=
7ou can see which #acka%es are #inned by issuin%
S,L,CT OWN,+? N-M,? TY/, 3+OM VPDB_OBN,CT_C-C6, W6,+, G,/T .
TY,SU
- :8 -
Oracle DBA Concise Handbook
7ou must ha$e $ery %ood knowled%e of a##lication to determine which obIects
to #in ri%ht after instance startu#. 7ou can audit P/CSD/ #acka%es& tri%%ers&
se'uences etc. and find out which obIects are most fre'uently accessed.
+.&.'./ Code re7se
4se bind $ariables like SE/EC" [ ;3O6 C4S"O6E3 ?HE3E C4S"F2D
P QcustFid
2m#lement strict codin% standard <i.e. ca#italiLation& indentation etc.= so that
chances of findin% identical statement in memory will increase.
+.&.'.0 T7ne cac9e s6eci;ic initiali<ation 6ara8eters
OPE(FC43SO3S <default :*& increase if necessary=
C43SO3FSPACEF;O3F"26E <set to ;A/SE for ;orms based a##lications=
SESS2O(FCACHEDFC43SO3S
C43SO3FSHA32(1 <use ;O3CE& S262/A3 or default EAAC"=
3.' -uning database bu**er cac(e
2t caches most recently accessed data blocks into memory. 2f data is not found
from cache& it is fetched from disk. 2t is o#erated on /34 mechanism <eMce#t&
only for full table scan& it is #laced on 634 end.=
Buffer may be free& #inned& clean or dirty.
DB?n writes dirty <chan%ed= buffer to disk.
3.3.1 -easurin# bu99er cache hit ratio
S,L,CT 1@=ph!sical5V-L0, @ irect5V-L0, @ lobs5V-L0,D 2
=logical5V-L0,D :B"((er cache hit ratio:
3+OM vPs!sstat ph!sical? vPs!sstat irect? vPs!sstat lobs?
vPs!sstat logical
W6,+, ph!sical5N-M, . #ph!sical reas#
-ND irect5N-M, . #ph!sical reas irect#
-ND lobs5N-M, . #ph!sical reas irect =lobD#
-ND logical5N-M, . #session logical reas#
"he ratio should be more than *.,* for O/"P systems.
- :+ -
Oracle DBA Concise Handbook
3.3.2 I,provin# bu99er cache hit ratio
+.4.'.1 Add 8ore s6ace
A/"E3 S7S"E6 SE" DBFCACHEFS2EE P **6
Set DBFn9FCACHEFS2EE #arameters in initialiLation file to access multi-
block database.
"o %et an idea how much you should increase buffer cache siLe
Set DBFCACHEFADB2CE P O( initialiLation #arameter.
Duery BNDBFCACHEFADB2CE $iew.
+.4.'.' Use 87lti6le b7;;er 6ools
4se kee#& recycle and default #ool by settin% DBF9EEPFCACHEFS2EE&
DBF3EC7C/EFCACHEFS2EE and DBFCACHEFS2EE <default= initialiLation
#arameters.
Determinin% which se%ments to cache in kee# and recycle #ools& you must ha$e
in de#th knowled%e of the a##lication.
S,L,CT "sername :o)ner:? N-M, :seg name:? 4in :seg t!pe:?
CO0NT=D*ST*NCT BLOCGED :No5 b"((ers:
3+OM vPcache v? ba_"sers
W6,+, v5o)nerE . 5"ser_i
<+O0/ BY N-M,? "sername? 4in
6-V*N< CO0NT=D*ST*NCT BLOCGEDK1H
O+D,+ BY O D,SC
Oracle recommends you consider cachin% of se%ments in kee# #ool whose total
siLe is less than *Y of default #ool siLe.
"o assi%n se%ments to #ool& use
A/"E3 "AB/E schema.#acka%e S"O3A1E <B4;;E3FPOO/ 9EEP=O
A/"E3 "AB/E schema.#acka%e S"O3A1E <B4;;E3FPOO/ 3EC7C/E=O
6onitor buffer #ool statistics
S,L,CT N-M, :B"((er pool:?
1@=ph!sical_reas2=b_bloc4_getsVconsistent_getsDD :B"((er
pool hit ratio:
- :: -
Oracle DBA Concise Handbook
3+OM vPb"((er_pool_statistics
O+D,+ BY N-M,
+.4.'.+ Cac9e tables in 8e8or:
C3EA"E "AB/E <\= CACHE
A/"E3 "AB/E name CACHE
+.4.'./ Use 6ro6er inde=es
Build indeMes on forei%n key columns of tables that reference a #rimary key
column in another table.
3.) &(ared ser0er
By default& Oracle runs on dedicated ser$er mode where for each user session
connection& a ser$er #rocess is created on ser$er and a user #rocess is created on
client machine. ?hen number of concurrent users becomes $ery hi%h& shared
ser$er <known as 6ulti "hreaded Ser$er in earlier $ersions= is used.
2n shared ser$er& se$eral <u# to := dis#atcher back%round #rocesses are run in
ser$er& which acce#t user re'uests. "hey then #ut the re'uest in a 'ueue.
"hereafter& shared ser$er #rocesses #ick the re'uest from 'ueue and #rocess the
SD/ <i.e. #arsin% the statement& readin% se%ments from disk and #lacin% them in
buffer cache etc.=. After #rocessin%& they #ut the result in res#onse 'ueue. "he
corres#ondin% dis#atcher sends back the result to user #rocess.
Shared ser$er is useful for these scenarios - many a##lication users& short
a##lication transactions <e.%. railway reser$ation system& order entry system=&
non-continuous transactions etc.
Shared ser$er is a scalability im#ro$ement feature not #erformance
im#ro$ement feature. 7ou will always ha$e same or better #erformance by
usin% dedicated ser$er feature.
3.4.1 %on9i#urin# shared servers
Set followin% #arameters in initialiLation file
D2SPA"CHE3S P n <* to :=
- :> -
Oracle DBA Concise Handbook
SHA3EDFSE3BE3S P n < to OS de#endent maM. $alue=
Other o#tional #arameters are - 6AAFD2SPA"CHE3S& C23C42"S&
6AAFSHA3EDFSE3BE3S& and P3OCESSES
3.4.2 -easurin# shared server per9or,ance
Duery on BNSHA3EDFSE3BE3F6O(2"O3 $iew.
"he followin% 'uery shows shared ser$er busy ratio
S,L,CT N-M,? ecoe=b"s!Vile?H?H?ro"n==b"s!2
=b"s!VileDD'1HH?BDD :b"s! rate: 3+OM vPshare_server W6,+,
stat"s W. #70*T#
"he neMt 'uery shows dis#atcher busy ratio
S,L,CT N-M, :ispatcher:? N,TWO+G? =ro"n=S0M=b"s!D2
=S0M=b"s!D2S0M=ileDD?BDD'1HH :b"s! rate:
3+OM vPispather <+O0/ BY N-M,? N,TWO+G
Additional dis#atcher is necessary is busy ratio found from abo$e 'uery is more
than :*Y.
Please note that DBA must connect throu%h dedicated ser$er to #erform $arious
DBA acti$ities <e.%. startu#Cshutdown database=.
3.1+ Large pool and :a0a pool
/ar%e #ool in S1A is used for 3eco$ery 6ana%er <36A(= o#erations and
#arallel 'uery.
2t is defined by /A31EFPOO/FS2EE <usual $alues from >**9 to )1B=
#arameter in initialiLation file and cannot be chan%ed dynamically.
0a$a #ool is used to kee# session s#ecific 0a$a a##lication code and $ariables.
2ts siLe is determined by 0ABAFPOO/FS2EE <default )*6= initialiLation
#arameter and cannot be chan%ed dynamically.
3.11-uning ,edo
- :5 -
Oracle DBA Concise Handbook
2ts #erformance is measured by the amount of time ser$er #rocess waits to
access redo lo% files. "he followin% 'ueries can be used to measure redo lo%
waits.
S,L,CT r5V-L0,2e5V-L0, :+eo log b"((er retr! ratio:
3+OM vPs!sstat r? vPs!sstat e
W6,+, r5N-M, . #reo b"((er allocation retries#
-ND e5N-M, . #reo entries#
2ts $alue should be less than Y.
S,L,CT N-M,?V-L0, 3+OM vPs!sstat W6,+, N-M, . #reo log space
re>"ests#
Constantly increase $alue indicates too small redo lo% files.
3.11.1 I,provin# redo lo# per9or,ance
6ake it bi%%er. 3edo lo% s#ace is s#ecified by /O1FB4;;E3 initialiLation
#arameter.
3educe redo lo% %eneration by usin% 4(3ECOBE3AB/E and (O/O112(1
keywords in SD/ statements.
3.12 -uning arc(i0ing operations
Common #roblems are -
Archi$e location %ettin% full - you can tem#orarily chan%e archi$e lo%
location by A/"E3 S7S"E6 A3CH2BE /O1 A// "O
XCoradataCarchi$eJ.
A3Cn #rocess canJt kee# u# with redo lo% %enerations - create more
A3Cn #rocess.
3.13 -uning disk I2O
9ee# se#arate table s#aces for different functional se%ments.
6easure data file 2CO from followin% $iews - BN;2/ES"A"& BNDA"A;2/E&
BN"E6P;2/E.
3.14 -uning sorts
6inimiLe sortin% acti$ity. 2f re'uired& #erform in memory whene$er #ossible.
- :@ -
Oracle DBA Concise Handbook
Sort may be measured by followin% 'uery
S,L,CT m5V-L0,2=5V-L0,Vm5V-L0,D :*n memor! sort ratio:
3+OM vPs!sstat m? vPs!sstat
W6,+, m5N-M, . #sorts =memor!D# -ND 5N-M, . #sorts =is4D#
"his ratio should be more than *.,:
2ncrease $alue for SO3"FA3EAFS2EE initialiLation #arameter if necessary.
Disk sort is #erformed in tem#orary table s#ace file.
3.15 -uning rollback segments
;rom Oracle ,i& automatic undo mana%ement does away manual rollback
se%ment mana%ement. Howe$er& you can set a s#ecific rollback se%ment for
lar%e transaction by this command -
C3EA"E P32BA"E 3O//BAC9 SE16E(" rbs S"O3A1E <2(2"2A/
6 (EA" *6= "AB/ESPACE rbstb
A/"E3 3O//BAC9 SE16E(" rbs O(/2(E
SE" "3A(SAC"2O( 4SE 3O//BAC9 SE16E(" rbs
EAEC #rocedure
A/"E3 3O//BAC9 SE16E(" rbs O(/2(E
3.1" Locks
/ock contention occurs when multi#le users try to obtain lock on s#ecific obIect
at the same time. /ock is released only after CO662" or 3O//BAC9
statement.
See lock contention from followin% $iews.
BN/OC9
BN/OC9EDFOB0EC"
DBAF?A2"E3S
DBAFB/OC9E3S
"o resol$e lock contention& a$oid codin% lon% transactions and donJt use
restricti$e eM#licit locks. 2t is always better to let Oracle handle all locks.
7ou can kill any session usin% A/"E3 S7S"E6 92// SESS2O( Xsid& serial_J
command.
- :, -
Oracle DBA Concise Handbook
3.1% -uning operating system
"ry to a$oid #a%in% and swa##in%.
2f ser$er has multi#le CP4s& use OracleJs #arallel 'uery& #arallel D6/& #arallel
A(A/7EE and #arallel indeM creation features. 2n multi#le CP4 machines&
Oracle will itself chan%e many #arameters.
7ou can allocate and mana%e ser$er resources usin% OracleJs 3esource
6ana%er feature <not discussed here=.
On 4niM& all ser$er #rocesses and back%round #rocesses are run as se#arate
eMecutables <you can see them usin% #s command=. Howe$er& on ?indows& all
those #rocesses run as threads inside O3AC/Eser+icename.EAE #rocess.
3.1' 7utomatic ;orkload ,epository 7;,!
;rom *%& A?3 continuously ca#tures database statistics and deri$es metrics
from it. "his is of immense hel# durin% database tunin%.
Amon% many others& A?3 collects followin% statistics
?ait e$ents used to identify #erformance #roblems.
Some system and session statistics from the BNS7SS"A" and
BNSESS"A" $iews.
ObIect usa%e statistics.
3esource intensi$e SD/ statements
A?3 information is used by ADD6 and SD/ "unin% Ad$isor <discussed
below=
A?3 related #acka%e is DB6SF?O39/OADF3EPOS2"O37. "he
DBAFH2S"Y $iews contain historical data stored in the database.
3.1) 7utomatic 3atabase 3iagnostic Monitor 733M! and &5L -uning
7d0isor
;rom *%& ADD6 constantly monitors database and in case of any #roblem& it
will su%%est what you should do neMt. "he ADD6 findin%s can be 'ueried from
DBAFADB2SO3Y obIects on data dictionary. (ote that ADD6 analysis is
based on A?3 sna#shots& which ha$e a default fre'uency of once an hour and a
default retention #eriod of @ days.
- >* -
Oracle DBA Concise Handbook
An ADD6 analysis is #erformed after each A?3 sna#shot <e$ery hour by
default=& and the results are sa$ed in the database.
3emember& the %oal of database #erformance tunin% is to reduce the DB time of
the system for a %i$en workload.

- > -
Oracle DBA Concise Handbook
* S7" and ("<S7"
All source code of #acka%es& #rocedures and functions are written in
DBAFSO43CE& A//FSO43CE or 4SE3FSO43CE $iews.
4.1 #ompiling packages
A/"E3 P3OCED43E #rocedure CO6P2/E
A/"E3 PAC9A1E #acka%e CO6P2/E
A/"E3 PAC9A1E #acka%e CO6P2/E BOD7
4.2 ,ecords and -ables
P/CSD/ records are similar to C structures.
D,CL-+,
TY/, t,mp *S +,CO+D =
,NO N0MB,+? 3N-M, V-+C6-+A=IHD? LN-M, V-+C6-+A=IHDD&
v,mp t,mp&
B,<*N
S,L,CT i? (name? lname *NTO v,mp 3+OM emplo!ee&
,ND&
7ou can use Y3O?"7PE to s#ecify a $ariable of table row ty#e. ;or eMam#le&
v,mp emplo!eeX+OWTY/,&
P/CSD/ "ables are similar to -dimensional array in C. 7ou can $isualiLe it as
a table with only ) columns - 9E7 and BA/4E.
D,CL-+,
TY/, t,mp *S T-BL, O3 V-+C6-+A=IHD *ND,9 BY B*N-+Y_*NT,<,+&
v,mp t,mp&
B,<*N
v,mp=1D . #Sai4at#&
,ND&
Some table attributes are - tablename.CO4("& DE/E"E& DE/E"E<i=& ;23S"&
/AS"& (EA"<i=& P32O3<i=.
4.3 #ursor
Declarin% cursor
- >) -
Oracle DBA Concise Handbook
C43SO3 cursorFname 2S SE/EC" statementO
Processin% cursor
OPE( cursorFnameO
;E"CH cursorFname 2("O $ariable<s=O
C/OSE cursorFnameO
Cursor attributes
Y;O4(D& Y(O";O4(D& Y2SOPE(& Y3O?CO4("
Cursor ;O3 loo#
;O3 $ariable 2( cursorFname /OOP
Statement<s=O
E(D /OOPO
4.4 Merge< multi 1 table insert and pi0ot insert
An eMam#le of mer%e command is shown below.
M,+<, *NTO M-N03-CT0+,+ M
0S*N< N,W_M-N03-CT0+,+ WM
ON =M5M3DNO . WM5M3DNOD
W6,N M-TC6,D T6,N 0/D-T,
S,T M5M3DN-M, . WM5M3DN-M,? M5-DD+,SS . WM5-DD+,SS? M5C*TY . WM5C*TY?
M5ST-T, . WM5ST-T,? M5CO0NT+Y . WM5CO0NT+Y
W6,N NOT M-TC6,D T6,N
*NS,+T =M5M3DNO? M5M3DN-M,? M5-DD+,SS? M5C*TY? M5ST-T,? M5CO0NT+YD
V-L0,S =WM5M3DNO? WM5M3DN-M,? WM5-DD+,SS? WM5C*TY? WM5ST-T,? M5CO0NT+YD&
Similarly& an eMam#le of multi - table insert follows.
*NS,+T -LL
W6,N M,D*- . TBOOGU T6,N
*NTO BOOG V-L0,S =NO? T*TL,? /+*C,D
W6,N M,D*- . TCDU T6,N
*NTO SO3TW-+, V-L0,S =NO? T*TL,? /+*C,D
W6,N M,D*- . TVCDU T6,N
*NTO V*D,O V-L0,S =NO? T*TL,? /+*C,D
S,L,CT M,D*-? NO? T*TL,? M,D*- 3+OM /+OD0CT&
4sin% #i$ot insert& you can create multi#le rows of data from sin%le record. Say&
SA/ESFSO43CEFDA"A comes from a non-relational source and it contains
followin% columns - em#Fid& salesFmon& salesFtue& salesFwed& salesFthu and
salesFfri. ?e like to store this information in SA/ESF2(;O table which has
- >8 -
Oracle DBA Concise Handbook
followin% fields - em#Fid& week& sales. ?e can achie$e it by usin% the
statement shown below.
*NS,+T *NTO S-L,S_*N3O V-L0,S =emp_i? )ee4? sales_monD
*NS,+T *NTO S-L,S_*N3O V-L0,S =emp_i? )ee4? sales_t"eD
*NS,+T *NTO S-L,S_*N3O V-L0,S =emp_i? )ee4? sales_)eD
*NS,+T *NTO S-L,S_*N3O V-L0,S =emp_i? )ee4? sales_th"D
*NS,+T *NTO S-L,S_*N3O V-L0,S =emp_i? )ee4? sales_(riD
S,L,CT emp_i? sales_mon? sales_t"e? sales_)e? sales_th"? sales_(ri 3+OM
S-L,S_SO0+C,_D-T-5
"hus for row in SA/ESFSO43CEFDA"A& we shall ha$e : rows in
SA/ESF2(;O table. "his feature is also known as normaliLation is some other
database a##lications.
4.5 &5L :oins
Oracle now follows A(S2C2SO Ioin syntaM <similar to SD/ Ser$er=. 7ou can
also use earlier $ersions Ioin syntaM. Howe$er& new A(S2C2SO standard syntaM
is more com#rehensi$e. Here are few eMam#les.
Say we ha$e ) tables - E6P <eno& ename& dno= and DEP" <dno& dname=. "o list
all em#loyee names and de#artment names we can now write followin% 'uery.
S,L,CT ,5,N-M,? D5DN-M, 3+OM ,M/ NO*N D,/T ON =,5DNO . D5DNOD
?e can use /E;"& 321H" or ;4// keywords for outer Ioin. ;or eMam#le& to
list all em#loyees e$en when some em#loyees may not belon% to any
de#artment& we can issue this 'uery.
S,L,CT ,5,N-M,? D5DN-M, 3+OM ,M/ L,3T NO*N D,/T ON =,5DNO .
D5DNOD
"his is definitely more intuiti$e than earlier syntaM with UZV o#eratorK
EMam#le of u#datin% columns of table with data from another tableQ
C+,-T, T-BL, *N3O1 =COD, V-+C6-+A=OD /+*M-+Y G,Y?
CO0NT+Y V-+C6-+A=1HHD? C-/*T-L V-+C6-+A=1HHD? /6ON,COD, N0MB,+=BD?
C0++,NCYCOD, V-+C6-+A=ODD&
*NS,+T *NTO *N3O1 V-L0,S =#*ND#?#*nia#?#Ne) Delhi#?N0LL?N0LLD&
*NS,+T *NTO *N3O1 V-L0,S =#<B+#?#0nite Gingom#?#Lonon#?N0LL?N0LLD&
*NS,+T *NTO *N3O1 V-L0,S =#3+-#?#3rance#?#/aris#?N0LL?N0LLD&
*NS,+T *NTO *N3O1 V-L0,S =#0S-#?#0nite States#?#Washington DC#?N0LL?N0LLD&
*NS,+T *NTO *N3O1 V-L0,S =#*T-#?#*tal!#?#+ome#?N0LL?N0LLD&
*NS,+T *NTO *N3O1 V-L0,S =#SW,#?#S)een#?#Stoc4holm#?BL?#S,G#D&
COMM*T&
C+,-T, T-BL, *N3OA =COD, V-+C6-+A=OD? /6ON,COD, N0MB,+=BD? C0++,NCYCOD,
- >+ -
Oracle DBA Concise Handbook
V-+C6-+A=OD D&
*NS,+T *NTO *N3OA V-L0,S =#*ND#?F1?#*N+#D&
*NS,+T *NTO *N3OA V-L0,S =#<B+#?BB?#<B/#D&
*NS,+T *NTO *N3OA V-L0,S =#3+-#?OO?#,0+#D&
*NS,+T *NTO *N3OA V-L0,S =#0S-#?1?#0SD#D&
*NS,+T *NTO *N3OA V-L0,S =#C-N#?1?#C-D#D&
COMM*T&
2' case 1 Y )rong '2
0/D-T, *N3O1 i1 S,T =/6ON,COD,?C0++,NCYCOD,D . = S,L,CT /6ON,COD,?
C0++,NCYCOD, 3+OM *N3OA iA W6,+, i15COD, . iA5COD, D
@@ S)een#s ata becomes n"ll b! r"nning thisWW
2' case A Y correct '2
0/D-T, *N3O1 i1 S,T =/6ON,COD,?C0++,NCYCOD,D . = S,L,CT /6ON,COD,?
C0++,NCYCOD, 3+OM *N3OA iA W6,+, i15COD, . iA5COD, D
W6,+, ,9*STS = S,L,CT 1 3+OM *N3OA iAA W6,+, i15COD, . iAA5COD,D
@@ S)een#s e1isting ata remains correct
4." /se*ul &5L *unctions
Decode - some eMam#les ha$e been #ro$ided in cha#ter U4seful scri#ts for
DBAsV.
Case - eMam#le
S,L,CT CO0NT+Y? CONT*N,NT
C-S, CONT*N,NT W6,N 1 T6,N T,0+O/,U
W6,N A T6,N T-S*-U
W6,N O T6,N T-3+*C-U
,LS, TOT6,+U ,ND CONT*N,NT_N-M,
3+OM CO0NT+*,S
?ith clause eMam#le
W*T6
1 -S
=
select #Tom# as 3irstName 3+OM "al "nion
select #Dic4# 3+OM "al "nion
select #Barne!# 3+OM "al "nion
select #Bett!# 3+OM "al
D?
Z -S
=
select #3lintstone# as LastName 3+OM "al "nion
select #+"bble# 3+OM "al
D
S,L,CT ' 3+OM 1?Z
(B/ <M& y= returns y if M is null or M otherwise.
(B/S <M& y& L= returns L if M is null& y if M is not null.
- >: -
Oracle DBA Concise Handbook
2(S"3 <strin% where to search& strin% what to search& start #osition default &
what Un-thV occurrence default
st
= is used for searchin% for #attern inside a
strin%. 3eturns the number #osition where occurrence has been found or * if not
found.
S4BS"3 <strin%& M& y= returns #ortion of strin% that is y characters lon% startin%
from #osition M.
3O4(D <:.):>@& )= #roduces :.)>.
Pi$ot and 4n-#i$ot eMam#les - can be used to trans#ose rowsCcolumns.
2' /*VOT '2
W*T6 (l!_table -S =
S,L,CT #Nohn# :C"stomer:?#-pple# :*tem:? I :7t!: 3+OM "al 0N*ON
-LL
S,L,CT #Nill#?#Orange#? A 3+OM "al 0N*ON -LL
S,L,CT #Sall!#?#Banana#? L 3+OM "al 0N*ON -LL
S,L,CT #Nohn#?#Orange#? A 3+OM "al 0N*ON -LL
S,L,CT #Sall!#?#-pple#? 1 3+OM "al 0N*ON -LL
S,L,CT #Nohn#?#Orange#? 1 3+OM "al 0N*ON -LL
S,L,CT #Sall!#?#-pple#? 1 3+OM "al
D
S,L,CT ' 3+OM =
S,L,CT :C"stomer:?:*tem:? S0M=:7t!:D :7t!: 3+OM (l!_table <+O0/ BY
:C"stomer:? :*tem:
D /*VOT = S0M=:7t!:D 3O+ :*tem: *N =#-pple#?#Banana#?#Orange#DD

2' 0N/*VOT '2
W*T6 (l!_table -S =
S,L,CT #*nia# :Co"ntr!:?#Ne) Delhi# :Capital: 3+OM "al 0N*ON
S,L,CT #0G#?#Lonon# 3+OM "al 0N*ON
S,L,CT #0S-#? #Washington DC# 3+OM "al 0N*ON
S,L,CT #<erman!#?#Berlin# 3+OM "al
D
S,L,CT COL? V-L0, 3+OM =
S,L,CT ' 3+OM (l!_table
D
0N/*VOT *NCL0D, N0LLS = V-L0, 3O+ COL *N =:Co"ntr!:?:Capital:DD
4.% 3ynamic 4L2&5L
A sam#le is %i$en below
C+,-T, T-BL, T,ST5,M/=NO N0MB,+? N-M, V-+C6-+A=1HHDD&
C+,-T, O+ +,/L-C, /+OC,D0+, D!nS>l
=pNo *N test5emp5noXTY/,?
pName *N test5emp5N-M,XTY/,D
- >> -
Oracle DBA Concise Handbook
-S
c"r *NT,<,+&
p *NT,<,+&
stmt V-+C6-+A=1HHD&
B,<*N
c"r $. bms_s>l5open_c"rsor&
stmt $. #*NS,+T *NTO T,ST5,M/ V-L0,S=$no?$nameD#&
bms_s>l5parse=c"r?stmt?bms_s>l5vJD&
bms_s>l5bin_variable=c"r?#$no#?pNoD&
bms_s>l5bin_variable=c"r?#$name#?pNameD&
p $. bms_s>l5,9,C0T,=c"rD&
COMM*T&
bms_o"tp"t5p"t_line=pD&
bms_s>l5close_c"rsor=c"rD&
,ND&
3un the #rocedure from SD/ Plus as ,9,C DYNS7L=1?#Sai4at#D&
2t is also #ossible to eMecute dynamic SD/ usin% EAEC4"E 266EDA"E as
shown below.
,9,C0T, *MM,D*-T,=T*NS,+T *NTO MY_T-BL, S,L,CT ' 3+OM
T6-T_T-BL,UD&
4.' 6ested table
create t!pe ob[-ress as ob[ect
=6o"seNo varcharA=AHD?
Street varcharA=AHHD?
Cit! varcharA=IHD?
State char=AD?
/ostCoe varcharA=1HDD
2
create t!pe o-ress as table o( ob[-ress
2
create table /eople
=No n"mber?
Name varcharA=1HHD?
-ress o-ressD
neste table -ress store as tb-ress&
insert into people val"es =1?#Sai4at Basa4#?
o-ress=ob[-ress=#1HH#?#,ast West
Street#?#Gol4ata#?#WB#?#JHHHHI#DDD
- >5 -
Oracle DBA Concise Handbook
2
4.) -ypes o* =oins
Su##ose we are Ioinin% two tables in Oracle.
S,L,CT T159? TA5Y 3+OM T1 NO*N TA ON T159 . TA59
Assume& " is dri$in% table <i.e. more rows than ")=
Nested oo6 >oin
"his is eMecuted like thisQ
;or each record in "
find matchin% record in ") where ".A P ").A
fetch that record into result set
(ow if there is no indeM on column A in ")& Oracle will #erform full table scan
for each record in ".
Has9 >oin
Oracle will load create an in-memory indeM <known as hash table= for ") <i.e.
smaller table=
2t will still #erform similar o#eration
for each record in "
find matchin% record in ") where ".A P ").A
fetch that record into result set
But e$en if there is no indeM on ").A& Oracle will use the hash table which
works similar to indeMK
Clearly this is suitable only when ") is small otherwise `a hash table may not
fit in memory `)a creation of hash table may in$ol$e a lon% time <then we could
ha$e created the indeM on ") in first #laceK=
"orted -erge >oin
- >@ -
Oracle DBA Concise Handbook
2f both tables are $ery bi%& hash Ioin is not suitable due to memoryCtime
re'uirement and nested loo# will be slow or will result in full table scan.
"he alternati$e way to s#eed u# #erformance is to use sorted mer%e Ioin.
2n this case& both tables are sorted by Oracle <usin% tem#orary table s#ace= by
Ioinin% key <A in this case=.
"he ad$anta%e is& when Ioinin% two tables& Oracle Iust needs to scan only a
small #art of the table <e.%. as they are sorted& to find a record in ") when ".A
P : will re'uire Oracle search Iust from AP* to AP)* in ") as it cannot be
beyond this ran%e and so on=.
"he trade off is& it will take some resource <s#aceCtimeCmemory= to sort the
tables.
4sually Oracle chooses best method of Ioin based on statistics a$ailable.
Howe$er& user may force usin% a different ty#e of Ioin usin% hints like
use%)as)-T./T01 etc.
- >, -
Oracle DBA Concise Handbook
4.1+ >.ternal tables
By creatin% eMternal tables& you can run SD/ statements on sim#le delimited
teMt filesK Howe$er& eMternal tables are read only i.e. you canJt u#date their data
usin% SD/ <you need to modify them in teMt editor=.
"o create an eMternal table& first you need to create a folder in your hard disk
where you will #lace the teMt files.
C+,-T, O+ +,/L-C, D*+,CTO+Y ,9T_T-BL,S -S
#,$%O+-CL,%O+-D-T-%,9T,+N-L_T-BL,S#
"he user& who will access eMternal table& should ha$e C3EA"E A(7
D23EC"O37 system #ri$ile%e.
(ow create the eMternal table in SD/ Plus as -
C+,-T, T-BL, -*+/O+T_COD,
=
COD, V-+C6-+A=OD?
C*TY V-+C6-+A=1HHD?
CO0NT+Y V-+C6-+A=IHD
D
O+<-N*R-T*ON ,9T,+N-L
=
TY/, O+-CL,_LO-D,+
D,3-0LT D*+,CTO+Y ,9T_T-BL,S
-CC,SS /-+-M,T,+S
=
+,CO+DS D,L*M*T,D BY N,WL*N,
3*,LDS T,+M*N-T,D BY #;#
M*SS*N< 3*,LD V-L0,S -+, N0LL
D
LOC-T*ON =#-*+/O+T5T9T#D
D
+,N,CT L*M*T 0NL*M*T,D
7ou can now run SD/ on the table.
- 5* -
Oracle DBA Concise Handbook
/ D-S (ac&a#es
5.1 3BM&?:OB
Check 0OBFD4E4EFP3OCESSES #arameter has non-Lero $alue in
initialiLation file.
B,<*N
SYS5DBMS_NOB5S0BM*T=
NOB .K $NOB?
W6-T .K #B,<*N 0/D-T,_-LL_T+-NS_/+*C,& ,ND&#?
N,9T_D-T, .K TO_D-T,=#11@HL@AHHB HF$IB$1I#? #DD@MM@YYYY
66AB$M*$SS#D?
*NT,+V-L .K #SYSD-T,V1I21BBH#D&
COMM*T&
,ND&
5.2 /-L?FIL>
A sam#le #rocedure to unload a table data to a teMt file usin% 4"/F;2/E
#acka%e is shown below.
Set 4"/F;2/EFD23 P XEQRO3AC/ERO3ADA"AR4(/OADJ <or #ath where
from you need to readCwrite= in initialiLation file.
C+,-T, O+ +,/L-C, /+OC,D0+, 0NLO-D_T-BL, =piTable *N V-+C6-+AD
-S
C0+SO+ cTable *S
S,L,CT ' 3+OM categor!&
( "tl_(ile5(ile_t!pe&
b"( V-+C6-+A=AHHD&
B,<*N
($.0TL_3*L,53O/,N=#,$%O+-CL,%O+-D-T-%0NLO-D#?#C-T,<O+Y5T9
T#?#)#D&
3O+ i *N cTable LOO/
b"($.i5Categor!No ;; #;# ;; i5Description ;; #;# ;;
i5/arentCategor!No&
0TL_3*L,5/0T_L*N,=(?b"(D&
,ND LOO/&
0TL_3*L,53CLOS,=(D&
DBMS_O0T/0T5/0T_L*N,=#T-BL, 0NLO-D,D#D&
,9C,/T*ON
W6,N OT6,+S T6,N
DBMS_O0T/0T5/0T_L*N,=S7L,++MD&
- 5 -
Oracle DBA Concise Handbook
,ND&
2
Similarly& 1E"F/2(E is used to read data from file.
- 5) -
Oracle DBA Concise Handbook
0 :se9ul scripts 9or DAs
".1 -o s(o$ primary2*oreign key relations(ips o* all tables and 0ie$s in
a gi0en sc(ema
S,L,CT
D5T-BL,_N-M, :Table name:?
D5CONST+-*NT_N-M, :Constraint name:?
D,COD,=D5CONST+-*NT_TY/,?
#/#?#/rimar! Ge!#?
#+#?#3oreign Ge!#?
#C#?#Chec42Not N"ll#?
#0#?#0ni>"e#?
#V#?#Vie) Cons#D :T!pe:?
D5S,-+C6_COND*T*ON :Chec4 Conition:?
/5T-BL,_N-M, :+e( Table name:?
/5CONST+-*NT_N-M, :+e( b!:?
M5COL0MN_N-M, :+e( col:?
M5/OS*T*ON :/osition:?
/5OWN,+ :+e( o)ner:
3+OM
DB-_CONST+-*NTS D
L,3T NO*N
DB-_CONST+-*NTS /
ON =D5+_OWN,+./5OWN,+ -ND
D5+_CONST+-*NT_N-M,./5CONST+-*NT_N-M,D
L,3T NO*N
DB-_CONS_COL0MNS M
ON =D5CONST+-*NT_N-M,.M5CONST+-*NT_N-M,D
W6,+,
D5T-BL,_N-M,
*N =
S,L,CT T-BL,_N-M, 3+OM DB-_T-BL,S W6,+,
OWN,+.0//,+=#m4m#D
0N*ON -LL
S,L,CT V*,W_N-M, 3+OM DB-_V*,WS W6,+, OWN,+.0//,+=#m4m#D
D
O+D,+ BY 1?A?O
".2 -o see all ob=ects in a table space *ile
S,L,CT
D5OWN,+?D5S,<M,NT_N-M,?D5S,<M,NT_TY/,?D5T-BL,S/-C,_N-M,?
D56,-D,+_3*L,?V5N-M,
3+OM
Dba_Segments D
- 58 -
Oracle DBA Concise Handbook
NO*N VPD-T-3*L, V ON =D56,-D,+_3*L,.V53*L,ED
W6,+,
D5OWN,+ *N =#MGM#D
".3 ;(ic( user e.ecuting $(at type o* command
S,L,CT
S*D?
S,+*-LE?
v5schemaname?
D,COD,=COMM-ND
?H?#None#
?A?#*nsert#
?O?#Select#
?L?#0pate#
?J?#Delete#
?M?#Drop#
?AL?#Loc4 Table#
?BB?#Commit#
?BI?#+ollbac4#
?BJ?#/L2S7L ,1ec"te#
?#Other#D comman
3+OM VPS,SS*ON v
".4 8et output o* a @uery to a te.t *ile *rom &5L 4lus
set pagesiZe IHHH
set linesiZe IHHH
spool 3$%T,M/%O0T/0T5T9T
set colsep :;:
select ' (rom MGM5/+OD0CT&
set colsep : :
spool o((
set pagesiZe IH
set linesiZe AHH
".5 -o see si9e o* your tables and inde.es
select S,<M,NT_N-M,? S,<M,NT_TY/,? BYT,S (rom 0S,+_S,<M,NTS
)here segment_t!pe *N =#T-BL,#?#*ND,9#D
"." -o see *ree spaces in table spaces
S,L,CT b5tablespace_name? b5:Total MB:? +O0ND=b5:Total MB: @
a5:3ree MB:?AD :0se MB:?
a5:3ree MB:? +O0ND===b5:Total MB:@ a5:3ree
MB:D2b5:Total MB:D'1HH?AD :X "se:
- 5+ -
Oracle DBA Concise Handbook
3+OM =
=S,L,CT (5tablespace_name? +O0ND=S0M=(5b!tes2=1HAB'1HABDD?AD
:3ree MB: 3+OM ba_(ree_space (
<+O0/ BY (5tablespace_nameD a
+*<6T NO*N
=S,L,CT 5tablespace_name? +O0ND=S0M=5b!tes2=1HAB'1HABDD?AD
:Total MB: 3+OM ba_ata_(iles
<+O0/ BY 5tablespace_nameD b
ON a5tablespace_name . b5tablespace_name
D
O+D,+ BY 1
- 5: -
Oracle DBA Concise Handbook
1 .ew 9eatures o9 16<11#
2)ic) are not co+ered in t)is boo3 so far. Any feature ')ic) is introduced in
.4*/ is also a+ailable in ..* 'it) usually more o(tions.
,las9back ?7er: @it9 c9anging data
7ou already ha$e flashback 'uery o#tion in Oracle ,i where you can 'uery
sna#shot of old data from undo table s#ace. But in *%& you can eMamine how
$alues chan%ed between two time #oints.
7ou can 'uery yesterdayJs $ersion of table data asQ
S,L,CT ' 3+OM /+OD0CT -S O3 T*M,ST-M/ SYSD-T,@1
Rollback 8onitoring
2n ,i& you canJt tell easily how much time it is %oin% to take to rollback a lar%e
transaction <until it is com#lete& the locks ac'uired by the transaction wonJt be
released=. 2n *% you can sim#ly %et this $ital information from
BNSESS2O(F/O(1OPS $iew.
I86roved table s6ace 8anage8ent
*% automatically creates a S7SA4A table s#ace durin% database creation. 2t is
used to hold data for se$eral of OracleJs su##ort schemas like DBS(6P& OD6
etc.
,las9back table
2n ,i& to restore a dro##ed table you need to use im#ort from back u# or do
incom#lete reco$ery. 2n *%& when a table is dro##ed& it %oes to OracleJs
3ecycle Bin and you can easily restore it from thereK 7ou can run followin%
command from SD/ Plus.
S,L,CT ' 3+OM DB-_+,CYCL,B*N
"o restore the table use - 3L-S6B-CG T-BL, schema.table_name TO
B,3O+, D+O/
Hey thatJs easyK
- 5> -
Oracle DBA Concise Handbook
"1 )l7s i86rove8ents
Se$eral enhancement has been made to SD/ Plus like #rom#tin%& im#ro$ed file
mani#ulations& fast D4A/ o#timiLation #lan etc.
A7to8atic "torage -anage8ent AA"-B
2n ,i& disk stora%e consideration <like 3A2D& stri##in%& lo%ical %rou#in% etc.=
was done manually. ;rom *% it can be done automatically with the hel# of
AS6.
R-AN i86rove8ent
Se$eral enhancements ha$e been made for incremental backu# methods.
A7diting i86rove8ents
(ow auditin% can be #erformed at $ery detail le$el <;1A - fine %rained audit=.
2n *%& auditin% will show you what user made eMactly what chan%es to data.
%ait inter;ace
Data dictionary $iews now show more information re%ardin% on user wait
e$ents& which will hel# to dia%nose wait #roblems better.
-ateriali<ed vie@ i86rove8ent
Oracle introduces materialiLed $iew ad$isor feature& which hel#s tunin%
materialiLed $iews. (ow Oracle ser$er can decide whether to rewrite the
materialiLed $iew or not dynamically.
-odel cla7se
4sin% 6ODE/ clause in SD/& you can treat multidimensional data as an array
in memory where you can a##ly s#readsheet like calculationsK
!nter6rise -anager A!-B c9anges
2ts architecture has been chan%ed in *%. 2tJs now installed as an H""P ser$er
<instead of as a client tool in ,i=. So& you will use it inside browserK 6oreo$er
lots of new features ha$e been added. See section .> for more information.
#irt7al )rivate Database i86rove8ents
- 55 -
Oracle DBA Concise Handbook
BPD was also in @i and ,i. But in *%& it has im#ro$ed to su##ort a $ariety of
re'uirements& such as maskin% columns selecti$ely based on the #olicy and
a##lyin% the #olicy only when certain columns are accessed. BPD has not been
discussed so far in this book. 2t is a method to im#lement security at finer %rain.
;or eMam#le& if you want to im#lement that lo%%ed on user will only see his
own records in database <e.%. seein% only his salary information from salary
table=& BPD can be set u# in such a way that Uwhere username P 4SE3V will be
automatically added to SD/s.
"eg8ent 8anage8ent
Se%ment s#aces can be mana%ed more efficiently. ?asta%e of s#ace in se%ments
is minimiLed. DBAs will ha$e more control o$er s#ace allocation.
Trans6ortable table s6ace
2n ,i& trans#ortable table s#aces can be #lu%%ed in to other databases only if
they run on same #latform. 2n *%& they can be #lu%%ed to database e$en
runnin% on different #latforms. "his is $ery hel#ful for data mo$ement across
different systems. Another im#ro$ement is that& data can be unloaded from
tables in $ery fast manner <in non-teMt format& thou%h= but the unloaded file&
a%ain& can be used across #latforms.
A7to8atic s9ared 8e8or: 8anage8ent
"he s#ace allocation for DB buffer cache& shared #ool& lar%e #ool and 0a$a #ool
can be set to mana%e automatically and dynamically as and when re'uired <i.e.
de#endin% on the database workload=K
"c9ed7ler
4sually dbmsFIob can be used only to run P/CSD/ #ro%rams. Howe$er& the
newly introduced dbmsFscheduler can e$en run OS commands at s#ecified
timeCinter$al.
Database re6la:
Startin% from %& you now ha$e o#tion of ca#turin% work load from a
#roduction database and re#lay that on test database to simulate li$e conditions.
- 5@ -
Oracle DBA Concise Handbook
%.1 ;(at is g in OracleAs grid computingB
Oracle defines %rid com#utin% like thisQ with %rid com#utin%& %rou#s of
inde#endent& modular hardware and software com#onents can be connected and
reIoined on demand to meet the chan%in% needs of businesses.
?hat does it eMactly meanH
?e already know what is #arallel com#utin%. A com#leM task is di$ided into
smaller #arts and each #art is #rocessed inde#endently by a com#uter. "hen the
out#uts are combined to %et final result.
How does %rid com#utin% differ from this #arallel com#utin%H
1rid com#utin% is an abstract <or $irtualiLation& as Oracle says= conce#t. A %rid
can be an infrastructure %rid& an a##lication %rid& an information %rid and so on.
?hat - %ettin% more confusedH Ok& #lease read on.
2n early days <b,@*s= of database& the relational database mana%ement was
startin% to %ain #o#ularity. 2n 3DB6S terms& a customer buys #roducts and a
transaction is %enerated. All these info like customer& #roduct& transaction etc.
are stored in 3DB6S. "hey are linked to%ether <by forei%n keys& in 8
rd
normal
form=. So from a hi%h le$el $iew& customer& #roduct& transaction are all #art of
3DB6S.
(ow come to the #resent days. ?e are %atherin% data like ne$er beforeK Besides
3DB6S& we now ha$e lots of different stuffs like O/AP <Business 2ntelli%enceC
Data ?arehouse etc.=& O/"P <transactional data=& BPE/ <Business Process
EMecution /an%ua%e=& ?eb ser$ices <usin% A6/=& O?B <Oracle ?arehouse
Builder= etc.
"he %rid is collection of all these - i.e. different a##lications and data which
s#eak with one another.
Oracle has #roduct of almost e$erythin% nowadays - which is wra##ed around a
fuLLy name called ;usion 6iddleware. "hese com#onents are desi%ned so that
one com#onent <say O?B= can interact with another <say core Oracle database=.
"his constitutes an architectural %rid.
"he relational data on your 3DB6S can be termed as information %rid.
"hereGs another as#ect of %rid. /et us take Oracle 3eal A##lication Cluster or
3AC. Here multi#le instances of database are inter-connected to safe%uard
- 5, -
Oracle DBA Concise Handbook
sin%le #oint of failure. "his is an eMam#le of infrastructure %rid. E$erythin% is
#art of %rid. 2t is a conce#t. 2t could ha$e been told as 6atriM com#utin% too.
<Did you enIoy 6atriM series of mo$iesH=
(ow you know what the buLLword 1rid com#utin% meanK
%.2 ;(at are Oracle Fusion Middle$are OFM! and &er0ice Oriented
7rc(itecture &O7!B
2f you are not sure about what are these thin%s and try to ha$e a look at OracleGs
website& there is a %ood chance that you mi%ht find yourself confused.
"hatGs 'uite eM#ected. OracleGs website is for marketin% their #roduct. 2tGs not
their interest to describe their #roducts in a way that #eo#le think it is there is no
ma%ic about itK
So& here 2 try to eM#lain the thin%s in non-%eeky terms.
"he ;usion 6iddleware consists of OracleGs non core-database #roducts - some
of which are not actually middlewareK
"his includes OracleGs De$elo#er suite <;orms . 3e#orts=& 0a$a related tools&
web lo%ic ser$er& content mana%ement etc. O;6 de#ends on o#en standards
such as BPE/& SOAP& A6/ and 06S.
Oracle SOA is a #art of O;6.
What is SOA?
"he main essence of SOA is that a##lications will talk with each other in a
lan%ua%e <i.e. data format& #rocess ste#s= which is understood by all others
a##lications communicatin% with.
SOA is about reuse.
SOA hel#s business to mo$e& chan%e& #artner and re-in$ent itself with ease and
%race.
SOA eMtends idea of reuse not only to web ser$ices but also with business
ser$ices.
SOA com#onents are loosely cou#led.
- @* -
Oracle DBA Concise Handbook
SOA can contain web ser$ice& BPE/ etc.
Web service
EMam#le& you throw a #ostcode to 7ahoo 1eo-coder and it %i$es you back
latitude& lon%itude of that #ost code.
7ou ask for #rice of #articular item to a website& it su##lies you the #rice.
4sually& web ser$ice results are returned in A6/ format to ensure uni$ersal
com#atibility.
2n SOA se%ment& you will often hear the term Orc)estration. ?hat does it
meanH
2f you seen an orchestra& you know that conductor Iust draws some in$isible
drawin%s in mid air by mo$in% his ma%ic wand from one side to another.
Howe$er& musicians can deci#her his rhythm and #lays their instruments so that
e$ery one #lays same tune at same #ace.
Orchestration in SOA has similar meanin%. 2t ensures that all a##lications under
SOA& know how to be in sync with other a##lications in the %rou#.
But how orchestration is im#lementedH
2t is done $ia BPE/ or Business Process EMecution /an%ua%e.
BPE/ is a tool& usin% which you can draw how data mo$es from one a##lication
to another. ;or those who ha$e not used it& it is like a Bisio flow chart dia%ram
editor. But& when you draw obIects in BPE/& you tell them what to do. 7ou
instruct them where to read data from& how to #rocess it and where to send
out#ut after #rocessin% finished. So& basically it is a %ra#hical tool to define
business #rocess. ?ithout BPE/& the whole #rocess will look like thousands of
lines of P/CSD/ <or 0a$a or CZZ or whate$er= codesK
Behind the scene BPE/ still writes codes - but it Iust make sim#ler <K= for any
business user to understand and define the #rocess. (ow whether that is %ood or
bad is debatable - 2 am Iust outlinin% the conce#t here.
So& BPE/ works to inte%rate se$eral a##lications. BPE/ usually follows A6/
standard as interface to se$eral com#onents.
- @ -
Oracle DBA Concise Handbook
/et us take a bi%%er eMam#le. 7our su##lier sends you a file which contains all
the #roducts& 'uantities and unit #rice you ordered for. 7ou need to u#date your
in$entory accordin%ly. (ow assume that your su##lier 'uoted the #rice in c but
you need to #ut that in d in your database. 4sin% absolute minimum technolo%y&
you need to write a small #ro%ram to con$ert c to d while loadin% that data to
your system. But if you are usin% BPE/& you can $isually draw the #ro%ramK
- @) -
Oracle DBA Concise Handbook
3 DA interview @uestions
Answers are not #ro$ided. Some 'uestions are basic and strai%htforward. Some
'uestions are o#en ended. 2f you co$er OCP curriculum& you will be able to
answer most 'uestions. "hese 'uestions are for DBAs with 8 - @ years of
eM#erience.
Please note that in most DBA inter$iews& besides core DBA 'uestions&
candidates are usually asked some 'uestions about the o#eratin% system <say
4niM= as well.
Concentrate on 'uestions de#endin% on the role actually re'uired in the
#osition.
'.1 OpenCended @uestions
. ?hat DBA acti$ities did you to do e$erydayH
). ?hat is your ty#ical day likeH
8. ?hat other #arts of your or%aniLation do you interact with and howH
+. Do you consider yourself a de$elo#ment DBA or a #roduction DBA and
whyH
:. ?hat database and o$erall architecture would you su%%est for testin% new
middleware without im#actin% #roductionH
>. How do you assess my databaseJs healthH
5. How would you a##roach a #erformance #roblem with a three-tier
a##licationH
@. How do you test your backu#Creco$ery #roceduresH
,. How would you su##ort the u#%rade #rocess for multi#le a##lications&
with different a##lication rollout cycles& in the same instanceH
*.?hat E3 tool <. $ersion= you usedH
.?hat should consist of D? "eamH
'.2 -ec(nical @uestions
3.2.1 Set 1
. EM#lain the difference between a hot backu# and a cold backu# and the
benefits associated with each.
). 7ou ha$e Iust had to restore from backu# and do not ha$e any control
files. How would you %o about brin%in% u# this databaseH
- @8 -
Oracle DBA Concise Handbook
8. How do you switch from an init.ora file to a s#fileH
+. EM#lain the difference between a data block& an eMtent and a se%ment.
:. 1i$e two eMam#les of how you mi%ht determine the structure of the table
DEP".
>. ?here would you look for errors from the database en%ineH
5. Com#are and contrast "34(CA"E and DE/E"E for a table.
@. 1i$e the reasonin% behind usin% an indeM.
,. 1i$e the two ty#es of tables in$ol$ed in #roducin% a star schema and the
ty#e of data they hold.
*.?hat ty#e of indeM should you use on a fact tableH
.1i$e two eMam#les of referential inte%rity constraints.
).A table is classified as a #arent table and you want to dro# and re-create
it. How would you do this without affectin% the children tablesH
8.EM#lain the difference between A3CH2BE/O1 mode and
(OA3CH2BE/O1 mode and the benefits and disad$anta%es to each.
+.?hat command would you use to create a backu# control fileH
:.1i$e the sta%es of instance startu# to a usable state where normal users
may access it.
>.?hat column differentiates the BN $iews to the 1BN $iews and howH
5.How would you %o about %eneratin% an EAP/A2( #lanH
@.How would you %o about increasin% the buffer cache hit ratioH
,.EM#lain an O3A-*::: <Sna#shot too old=
)*.EM#lain the difference between NO3AC/EFHO6E and
NO3AC/EFBASE.
).How would you determine the time Lone under which a database was
o#eratin%H
)).EM#lain the use of settin% 1/OBA/F(A6ES e'ual to "34E.
)8.?hat command would you use to encry#t a P/CSD/ a##licationH
)+.EM#lain the difference between a ;4(C"2O(& P3OCED43E and
PAC9A1E.
):.EM#lain the use of table functions.
)>.(ame three ad$isory statistics you can collect.
)5.?here in the Oracle directory tree structure are audit traces #lacedH
)@.EM#lain materialiLed $iews and how they are used.
),.?hen a user #rocess fails& what back%round #rocess cleans u# after itH
8*.?hat back%round #rocess refreshes materialiLed $iewsH
8.How would you determine what sessions are connected and what
resources they are waitin% forH
8).Describe what redo lo%s are.
88.How would you force a lo% switchH
8+.1i$e two methods you could use to determine what DD/ chan%es ha$e
been made.
8:.?hat does coalescin% a table s#ace doH
- @+ -
Oracle DBA Concise Handbook
8>.?hat is the difference between a "E6PO3A37 table s#ace and a
PE36A(E(" table s#aceH
85.(ame a table s#ace automatically created when you create a database.
8@.?hen creatin% a user& what #ermissions must you %rant to allow them to
connect to the databaseH
8,.How do you add a data file to a table s#aceH
+*.?hat $iew would you use to look at the siLe of a data fileH
+.?hat $iew would you use to determine free s#ace in a table s#aceH
+).How can you rebuild an indeMH
+8.7ou ha$e Iust com#iled a P/CSD/ #acka%e but %ot errors& how would
you $iew the errorsH
++.How can you %ather statistics on a tableH
+:.How can you enable a trace for a sessionH
+>.?hat is the difference between the SD/[/oader and 26PO3" utilitiesH
+5.(ame two files used for network connection to a database.
3.2.2 Set 2
. A user has connect and resource #ri$ile%es allocated by the DBA. He is
been allocated 'uota on three table s#aces by the DBA& - Default "able
s#ace Duota :** 6& "able s#ace Duota ** 6& "able s#ace ) Duota
)** 6. (ow the user tries to make a table& which uses 8** 6 in table
s#ace ). ?ill he be successfulH
). After a table is defined& can columns be remo$edH
8. Can we add columns to a table& which is already definedH
+. Can you eM#lain reco$ery of in a 3DB6SH
:. Describe the #rocedure for mo$in% a data file from one disk to another.
Show actual SD/ used for this #rocedure.
>. Difference . when to use ;23S"F3O?S . A//F3O?S #arameter&
while usin% an o#timiLer
5. EM#lain B-"ree indeMH
@. EM#lain com#osite indeMH
,. EM#lain different kind of lockin% in 3DB6SH
*.EM#lain the definition of a ^star schema.^
.EM#lain the difference between a ^hot^ and a ^cold^ backu#. ?hat is
in$ol$ed with eMecutin% a ^hot^ backu#H
).EM#lain the differences between lo%ical and #hysical database backu#s.
?hat are the benefits and #enalties of eachH
8.EM#lain the #rocessin% of a #ro%ram usin% cursorH
+.EM#lain third normaliLed formH
:.EM#lain two #hase commitH
- @: -
Oracle DBA Concise Handbook
>.EM#lain what a bitma##ed indeM is& what its a##lications would be& and
why itGs useful.
5.EM#lain what an Oracle sna#shot is.
@.Ha$e you heard about "uMedo& Encina& C2CSH
,.How can one im#licitly disconnect a user from the database& who is idle
for a lon% timeH <4sin% Profiles=
)*.2s it #ossible that there could be #erformance de%radation due to so many
indeMesH ?hen and howH
).Duestions were asked about #arameters in eM#ort& likeQ consistent P y&
<what is the #ur#ose of it=H
))."here are ** data files& numbered from to **. ;ile number * is
deleted and it has :** 6B of data. "he database is workin% in (o-
Archi$e lo% mode. How can the database be reco$eredH
)8."here are about a *&*** records in a table. 4ser runs a 'uery& which is
doin% a full-table scan. ?hile doin% the full table scan& user ) chan%es
some $alue M to y usin% a D6/ statement in record. ?hat does the
st
user see <M or y=H 2f M& then where is the $alue storedH <3ollback
Se%ments=.
)+.?hat 3DB6S obIects are re'uired before you can create a tableH
):.?hat are the contents of a Control ;ileH
)>.?hat are the different data structures used for indeMesH
)5.?hat are the ty#es of reco$ery one can #erformH
)@.?hat can you do with an alias that you cannot do with a synonymH
),.?hat is (ormaliLationH
8*.?hat is a correlation name and eM#lain the usa%eH
8.?hat is a cursorH
8).?hat is a forei%n keyH
88.?hat is a IoinH EM#lain outer Ioin with an eMam#leH
8+.?hat is a #a%e in 3DB6SH
8:.?hat is a #artitioned tableH
8>.?hat is a stored #rocedureH ?hy there are re'uiredH
85.?hat is a sub 'ueryH
8@.?hat is a synonymH
8,.?hat is a $iewH
+*.?hat is commit and rollbackH
+.?hat is distributed transaction #rocessin%H
+).?hat is lo%%in% in a 3DB6SH
+8.?hat is #rimary keyH
++.?hat is 'uery eMecution #lanH
+:.?hat is 'uery o#timiLerH
+>.?hat is referential inte%rityH
+5.?hat is the SD/ statement necessary to delete a user named ^0oe^ and
e$erythin% that he owns in a databaseH
- @> -
Oracle DBA Concise Handbook
+@.?hat is the difference between a searched u#date and a #ositioned
u#dateH
+,.?hat is the difference between static SD/ and dynamic SD/H
:*.?hat is the im#ortance of redo lo% filesH
:.?hat is the sa$e #oint in a transactionH
:).?hat is the use of /29EH
:8.?hat is the use of the #arameter ^6AA"3A(SV. 2s it used at block le$el&
eMtent le$el or se%ment le$elH
:+.?hat is transition monitorH
::.?hat is transactionH EM#lain atomic #ro#erty of a transactionH
:>.?hat $ariables in the ^2(2".O3A^ file affect the amount of 3A6 needed
for the S1AH
:5.?hatGs the default #assword for the Oracle user ^Scott^H
:@.?here and when can we use the HAB2(1 clauseH
:,.?hich SD/ error will you %et when you try to fetch data from a cursor
after it has run out of dataH
>*.?hich #arameter can be used to enable check #ointin% at re%ular inter$als
<;AS"FS"A3"F6""3F"A31E"=H
>.?hich #arameter do you use to read multi#le blocks in one %o
<DBF64/"2B/OC9F3EADFCO4("=
>).?hy a stored #rocedure su##oses to %i$e better #erformanceH
>8.?hy indeMes are so im#ortantH
>+.?hy is the difference between Direct Path EM#ort and Con$entional Path
EM#ortH
>:.?hy it is bad to use the SE/EC" [ in static SD/H
>>.?hy row le$el lockin% is desiredH
>5.?hy would you use 4(2O( instead of a 0O2(H
3.2.3 Set 3
. ?hat data warehouse features are there in Oracle ,iH
). ?hat is the difference between B-"ree . Bitma# indeMH EM#lain.
8. ?hat is dimension tableH
+. ?hat is surro%ate keyH
:. ?hat is 8rd normaliLationH
>. ?hat is ref cursorH
5. ?hat is materialiLed $iewH
@. ?hat is 'uery rewriteH
,. ?hat is inline $iewH
*.?hat is conformed dimensionH
.?hat is slowly chan%in% dimensionH
- @5 -
Oracle DBA Concise Handbook
).How E3 dia%ram differs from D? dimensionH <Answer - O/"P schema
$s. Star schema=
8.?hat is ty#e& ty#e)& ty#e8 related to dimensionH
+.?hat is the difference between to# down and bottom u# a##roachH
:.?hen is full-table scan beneficialH
>.?hat #erformance tunin%s you ha$e doneH
5.4#date Em# set salaryP:*** where idP** - eM#lain all ste#s that
ha##ens internally.
@.State differences between @i and ,iH
,.State differences between ,i and *%H
)*.?hat #arameters of database you canGt chan%e without recreatin% oneH
<Answer - block& buffer& and character set etc.=
).?hat is asynchronous P/CSD/ blockH
)).?hat Oracle books you readH
)8.?hat is autonomous transactionH
)+.?hat are $arious ty#es of transactionsH
):.?hat eMtra Oracle features you like to seeH
)>.EM#lain B "ree . Bitma# indeM.
)5.EM#lain clearly what will ha##en if 2 indeM a %ender column usin% B tree
instead of Bitma#.
)@.?hat is basically stored in indeMH
),.2f a table has no rows& does it take any s#aceH
8*.?hat lar%est database you ha$e handledH How many tables were thereH
8.?hat is two #hase commitH
8).?hat is distributed databaseH
88.?hat is 3AC . what is its ad$anta%eH
8+.How do you handle eMce#tion in P/CSD/ #rocedureH
8:.?hat is the ad$anta%e or #acka%e o$er #rocedureH
8>.?hat is #ra%ma-restricted functionH
85.?hat are CoydGs %olden rules <not about normaliLation=H
8@.How do you su%%est backu# strate%y of #roduction databaseH
8,.?hat database challen%es you faced in your last #roIectH
+*.?hat is )nd normaliLationH
+.?hen do you de-normaliLe dataH
+).?hat database tunin% you ha$e doneH
+8.?hat is the len%th of rowid dataH
++.?hat Oracle analytic functions you ha$e usedH
+:.Can you s#ecify se'uence in SD/ loaderH
+>.EM#lain directCindirect loadH
+5.?hat are different com#onents of S1AH ?hat are different back%round
#rocessesH ?hat are functions of each of themH
+@.?hat is 3eco #rocessH
+,.How do you see all columns of all tablesH
- @@ -
Oracle DBA Concise Handbook
:*.EM#lain im#licit . eM#licit cursor.
:.How do you declare record ty#e $ariableH
:).?hat is P/CSD/ tableH Define itGs syntaM.
:8.How do you select du#licate rows from a tableH
:+.How do you a$oid fra%mentationH
::.EM#lain deadlock with an eMam#le.
:>.?hy #eo#le sometimes donGt run database in archi$e lo% modeH
:5.?hat does DB?3 . /1?3 doH
:@.?ho write data in database buffer cache . redo lo% bufferH
:,.Can you %et back se'uence $alues already %eneratedH
>*.EM#lain shared ser$er conce#t.
>.?hen a new session starts& how do you see eMtra #rocesses created from
data dictionary tablesH
>).?here do you find all database obIectsH
>8.?here the source of functionC#rocedures is storedH
>+.?hat do you know about Standby database . 3e#licationH
>:.?hat are different ty#es of backu#sH
>>.EM#lain all ste#s of com#lete . incom#lete reco$ery.
>5.?hat are $arious ty#es of reco$eriesH EM#lain.
>@.?hat database tunin% you ha$e doneH
>,.?hat tunin% tools you ha$e usedH
5*.?hat database desi%n you ha$e #erformedH
5.?hat backu# method you su%%est for a )+M5 #roduction databaseH
5).EM#lain some tunin% methods.
58.EM#lain $arious com#onents of S1A.
5+.?here does init.ora resideH
5:.Did you install Oracle ser$erH
5>.?hen do you %o for im#ortCeM#ort instead of backu#H
3.2.* Set * (S7"!
. ?hat is wron% with followin% 'ueryQ SE/EC" column& column)&
AB1<column8=& column+ ;3O6 table 13O4P B7 column& column)
). ?hat is wron% with this 'ueryQ SE/EC" AB1<CO4("<em#loyeeFid=
;3O6 em#loyee 13O4P B7 de#t
8. How do you delete du#licate rows from a table usin% SD/H `Ans - delete
from du#Ftest d where rowid not in <select maM<rowid= from du#Ftest d)
where d.num P d).num=a
+. How do you identify du#licate rows in a tableH
:. A table has followin% columns - de#tartment& em#loyeeFname and
salary. How do you list a$era%e salary of all de#artmentsH
>. How do you find databaseJs time LoneH `select dbtimeLone from duala
- @, -
Oracle DBA Concise Handbook
'.3 5uestions you s(ould ask
?hat #rocesses do you follow while im#lementin% chan%es in #roductionH
Beside the DBAs and system administrators& who has access to the ^Oracle^
o#eratin% system accountH
How often is the oracle o#eratin% system account #assword chan%edH
Are the DBAs co-located with the teams they su##ortH
How is ca#acity #lannin% #erformedH
2s there ade'uate ca#acity already in #lace to su##ort the eM#ected %rowth o$er
the neMt yearH
2s there a formal Iob definition for the DBA roleH
2s there a defined technical career #athH
How is 2" ali%ned with the business areasH
How many em#loyees re#ort to more than one mana%erH
How do you determine if a DBA has been successfulH
How are the a##lication DBAs and #roduction control DBAs or%aniLedH
- ,* -
Oracle DBA Concise Handbook
4 $e9erences
Oracle classroom course #resentations
OCACOCP Oracle books <DBA 2& DBA 22& Performance "unin%& SD/=
from BPB #ublications.
Oracle manuals
Oracle Press DBA and P/CSD/ books
Classroom course at SD/ Star 2nternational& Calcutta.
htt#QCCdownload.oracle.comCdocsCcdCB)@8:,F*Crac.Cb)@):).#df
htt#QCCwww.oracle.comCtechnolo%yC#ubCarticlesCchanFsin%)racFinstall.ht
ml
htt#QCCwww.orafa'.comCwikiC3ACF;AD
- , -
Oracle DBA Concise Handbook
16 Oracle serverAs dia#ra,,atic overview
- ,) -
S1A
Database buffer cache
9ee#
3ecycle
Default
3edo lo% buffer cache
/ar%e #ool <o#tional=
0a$a #ool <o#tional=
Shared #ool
Data
dictionary
cache
Control
structures
/ibrary cache
Shared SD/
P/CSD/
#rocedures
. #acka%es
/ocks and
other
structures
3edo lo% files
4ser
connection
Ser$er #rocess created
for userJs connection
Data files - System .
SysauM table s#ace&
4ndo table s#ace&
A##lication data table
s#aces etc.
Parameter file
<3ead when
database starts=
P
1
A
Control file -
synchroniLation information
for all Oracle files

You might also like