Oracle DBA Concise Handbook
Oracle DBA Concise Handbook
Oracle DBA Concise Handbook
Saikat Basak
-1-
Oracle DBA Concise Handbook
© Saikat Basak
The author and publisher of this book have used their best efforts in preparing
this book. These efforts include the development, research and testing of the
theories and programs to determine their effectiveness. The author and publisher
shall not be liable in any event for the incidental or consequential damages in
connection with, or arising out of, the furnishing, performance, or use of these
programs.
All rights reserved. No part of this book may be reproduced, in any form or by
any means, without the permission in writing from the author.
-2-
Oracle DBA Concise Handbook
Contents
INTRODUCTION...............................................................................................6
1 ORACLE SERVER – AN OVERVIEW...................................................7
1.1 LOGICAL STRUCTURE .............................................................................7
1.2 ORACLE MEMORY STRUCTURE ...............................................................7
1.3 BACKGROUND PROCESSES ......................................................................9
1.4 INSTALLING AND MANAGING ORACLE DATABASE ................................12
1.5 ORACLE MANAGED FILES (OMF)........................................................12
1.6 CREATING A NEW DATABASE ...............................................................12
1.7 STARTING UP DATABASE INSTANCE ......................................................15
1.8 SHUTTING DOWN DATABASE INSTANCE ................................................15
1.9 CONTROL FILE ......................................................................................15
1.10 REDO LOG FILES ...................................................................................17
1.11 TABLE SPACES ......................................................................................20
1.12 SEGMENT AND STORAGE STRUCTURES .................................................23
1.13 TABLES ................................................................................................24
1.14 INDEXES ...............................................................................................26
1.15 CONSTRAINTS ......................................................................................27
1.16 USERS AND SECURITY ..........................................................................29
2 BACKUP AND RECOVERY ..................................................................32
2.1 INTRODUCTION.....................................................................................32
2.2 BACKUP AND RECOVERY IN NO ARCHIVE LOG MODE ............................32
2.3 BACKUP IN ARCHIVE LOG MODE ...........................................................32
2.4 USER MANAGED COMPLETE RECOVERY ................................................33
2.5 USER MANAGED INCOMPLETE RECOVERY ............................................34
2.6 LOGICAL BACKUP – EXPORT/IMPORT AND DATA PUMP ........................34
2.7 SQL LOADER .......................................................................................36
2.8 NETWORKING FUNDAMENTALS ............................................................37
2.9 LOG MINER ..........................................................................................39
2.10 REAL APPLICATION CLUSTERS (RAC).................................................42
2.11 STANDBY DATABASE (ALSO ORACLE DATA GUARD) ...........................44
2.12 REPLICATION .......................................................................................44
3 PERFORMANCE TUNING ....................................................................45
3.1 TUNING DEVELOPMENT AND PRODUCTION SYSTEMS ............................45
3.2 SOURCES OF TUNING INFORMATION .....................................................45
3.3 COLLECTING STATISTICS ......................................................................46
3.4 ORACLE SUPPLIED GUI TUNING TOOLS ................................................47
3.5 SQL APPLICATION TUNING AND DESIGN ...............................................47
3.6 OPTIMIZER ...........................................................................................49
-3-
Oracle DBA Concise Handbook
-4-
Oracle DBA Concise Handbook
-5-
Oracle DBA Concise Handbook
Introduction
There are several books available in the market for Oracle DBAs. So what is
special about this book?
Well, the differences are several. First of all, this book is available in electronic
format. You can carry this book wherever you want. It is written in simple
Word format (PDF format is also available). So, you can open it in almost
anywhere. This book is based on the commands necessary for regular DBA
activities. This is a concise book. It attempts to be your first reference for DBA
job. You will still require looking at Oracle manuals and other huge references
for advanced commands and features. Please note that this book does not try to
teach you how to be a DBA. It is assumed that you know a bit of DBA
activities. It only acts as a DBA handbook.
This is really a CONCISE handbook. That’s why I couldn’t cover every nuts
and bolts of Oracle. Had I do so, this book would have consisted of more than
1000 pages and its charm would have been lost! Only the most basic aspects
have been touched. So, please don’t yell that why such and such topics have
been left. However, if readers strongly feel that some topics need to be added, I
shall definitely honor that demand.
I shall occasionally update the book. So, please visit the website frequently to
download latest version of the book.
Please note that originally I wrote this book for Oracle 9i and then updated for
11g.
-6-
Oracle DBA Concise Handbook
Database
Tablespace Segment
Segment 1
Blocks
Extent 1
Segment 2
Extent 1
1.2.1 SGA
System Global Area (SGA) is shared memory area. All users of database share
information maintained in this area. The SGA and other background processes
constitute an Oracle instance.
From 11g, Oracle can manage SGA and PGA completely automatically.
-7-
Oracle DBA Concise Handbook
Shared memory
SGA
Database buffer cache Shared pool
Library cache
Data
dictionary Shared SQL
Keep Recycle Default cache
PL/SQL
Redo log buffer cache procedures
& packages
Control
structures
Large pool (optional) Locks and
other
structures
Java pool (optional)
From 11g, there are two new components in SGA viz Streams pool and Result
cache.
Non-shared memory
PGA
The database buffer cache is the area of memory that caches database data,
holding blocks from data files that have been read recently. Before a user can
look at a piece of information in an Oracle database, it must first reside in the
database buffer cache. Data gets into this cache based upon the Most Recently
Used algorithm. Because the most recently and most frequently used data is
kept in memory, less disk I/O is necessary, and overall database performance is
improved.
-8-
Oracle DBA Concise Handbook
DB_CACHE_SIZE, DB_KEEP_CACHE_SIZE,
DB_RECYCLE_CACHE_SIZE determines DB cache size.
Redo log buffer is a circular buffer in SGA that holds information about
changes made to data.
Library cache contains shared SQL area, PL/SQL procedures and packages etc.
It is used for maintaining recently executed SQL commands and their execution
plans.
Oracle marks buffers in memory as dirty when the data they contain is changed.
DBWn writes content of dirty buffer to data file when – a server process can’t
find a clean buffer after searching set threshold of buffers, a checkpoint occurs,
change table space to read only/offline/backup mode, drop/truncate table etc.
-9-
Oracle DBA Concise Handbook
It is responsible to redo log buffer management. Almost all activities against the
database are tracked in the online redo logs. As transaction are initiated and
eventually committed or rolled back, a record of this activity is written to these
log files.
At startup, SMON’s job is to ensure that all the database files are consistent and
perform recovery if required. There is also an assortment of other cleanup
activities that may need to be done, which are SMON’s responsibility. The
SMON process by itself checks every so often to see whether there are any tasks
waiting for its attention.
Cleans up failed user processes and frees all resources used by failed process.
- 10 -
Oracle DBA Concise Handbook
It is used in RAC.
From 10g, it makes snapshots of the database’s health (statistics) and stores this
information in the automatic workload repository.
- 11 -
Oracle DBA Concise Handbook
Usually when you install Oracle, it automatically creates a database for you
(though you need to specify a database name for this). Otherwise, you usually
use graphical Database Configuration Assistant (DBCA) to create/manage
databases. So, you may not even require creating a database from command
prompt. However, in case you need to, the steps are shown below.
- 12 -
Oracle DBA Concise Handbook
BACKGROUND_DUMP_DEST=F:\MYDB\BDUMP
CORE_DUMP_DEST=F:\MYDB\CDUMP
USER_DUMP_DEST=F:\MYDB\UDUMP
DB_NAME= sid_name
INSTANCE_NAME= sid_name
UNDO_MANAGEMENT=AUTO
UNDO_TABLESPACE=UNDO01
STARTUP NOMOUNT
- 13 -
Oracle DBA Concise Handbook
Note: Above command was for Oracle 9i. From 10g, you need Sysaux table
space as well.
Now run calalog.sql (creates data dictionary views) and catproc.sql (creates
PL/SQL packages) from $ORACLE_HOME\RDBMS\ADMIN
After installing Oracle, several services are registered in the server computer. In
Windows, (for Oracle 9.2) following services must be started as a minimum to
run Oracle – OracleOraHome92Agent, OracleOraHome92TNSListener and
OracleServiceSID (where SID is the name of database you created).
In Windows Vista running Oracle 11g, I usually start/stop my test database via
following batch file (say StartOracle.bat – MYDB is name of my database)
To stop database services, you can create a similar batch file by replacing start
with stop. In Vista, you need to run these batch files as administrator.
For various day-to-day database works, you may find SQL Plus cumbersome to
work with. For this, several 3rd party GUI tools are available. Two most popular
tools are – PL/SQL Developers and TOAD. From 11g, Windows SQL Plus has
been replaced by SQL Developer suite bundled with 11g. DOS version of SQL
Plus is still available though!
- 14 -
Oracle DBA Concise Handbook
NB: Oracle 11g requires at least 1 GB of RAM and 5 GB disk space to install.
For an operational production database, more RAM and disk space are required.
- 15 -
Oracle DBA Concise Handbook
Oracle backs up control file after any structural changes in database. LGWR
updates control file with current log sequence number. CKPT updates control
file with recent checkpoint information. ARCn updates with archiving
information.
Using init.ora
CONTROL_FILES =
(‘/ora/oradata/mydb/control1.ctl’, ‘/ora/oradata/mydb/control1.ctl’)
Using spfile
2. SQL>SHUTDOWN NORMAL
3. Copy control file to new location
4. SQL>STARTUP
Make sure you have complete list of all data and log files.
- 16 -
Oracle DBA Concise Handbook
MAXLOGFILES 10
MAXLOGMEMBERS 5
MAXINSTANCES 1
MAXLOGHISTORY 1
DATAFILE
'F:\MYDB\DATAFILES\SYSTEM01.DBF'
'F:\MYDB\DATAFILES\USERS01.DBF'
'F:\MYDB\DATAFILES\UNDO01.DBF'
'F:\MYDB\DATAFILES\TEMP01.DBF'
LOGFILE
GROUP 1 'F:\MYDB\LOG\LOG01.DBF' SIZE 10M,
GROUP 2 'F:\MYDB\LOG\LOG02.DBF' SIZE 10M
/
V$CONTROLFILE
V$CONTROLFILE_RECORD_SECTION
Redo entries record data changes that can be used to reconstruct all changes
made to database. Whenever you do any change to database (DML or DDL), it
is recorded in redo logs.
Usually in production databases, there are at least 3 redo log groups and each
group has at least 2 redo log members. Note that, all member files under same
group are identical. Members are multiple copies to protect against data loss in
case of disk failure.
- 17 -
Oracle DBA Concise Handbook
For OMF
ALTER DATABASE ADD LOGFILE
- 18 -
Oracle DBA Concise Handbook
First, make the log file inactive, if necessary, issue ALTER SYSTEM SWITCH
LOGFILE
In 11g, to enable database archive log mode, define archive location like this
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=C:\Oracle11g\oradata\MYDB\archivelog'
SCOPE=SPFILE; (in mount state)
LOG_ARCHIVE_FORMAT = ‘arch_%t_%s’
- 19 -
Oracle DBA Concise Handbook
The database’s data is stored logically in table spaces and physically in data
files corresponding to the table spaces. One table space can have multiple data
file but one data file must belong to only one table space. A single object (say a
table) may span multiple data files but must reside within a single table space.
- 20 -
Oracle DBA Concise Handbook
From Oracle 10g onwards, you can rename a table space (except System and
Sysaux)
When you rename a table space, all corresponding data dictionary entries are
updated.
- 21 -
Oracle DBA Concise Handbook
Follow these steps to rename data file (for single table space except System
table space)
In case of System table space or table spaces with multiple data files
Shutdown database
Copy or move the file to new location with OS commands
Startup database in mount state
ALTER DATABASE RENAME FILE
'c:\oracle\oradata\mydb\supermarket_data2.dbf' TO
'c:\oracle\oradata\mydb\supermarket_new.dbf'
Open database
- 22 -
Oracle DBA Concise Handbook
Please note in case of Windows, the file may get locked unless database is
shutdown.
V$DATAFILE
V$TEMPFILE
DBA_DATA_FILES
DBA_TEMP_FILES
Types of segments are – table, table partition, cluster, nested table, index, index
organized table, index partition, temporary, LOB, undo, bootstrap.
When a user performs an update or deletes operation, the earlier data is saved to
undo segments and then actual data is modified to new value. In case of insert
operation, rowid of new rows are stored in undo segments.
Undo data is not deleted immediately after commit or rollback. How long it will
stay in undo segment depends on UNDO_RETENTION parameter in
initialization file.
When a transaction is rolled back, Oracle restores the earlier data from undo
segments.
- 23 -
Oracle DBA Concise Handbook
UNDO_MANAGEMENT=AUTO
UNDO_TABLESPACE=table space name
DBA_EXTENTS
DBA_FREE_SPACE
DBA_SEGMENTS
V$SORT_SEGMENT
DBA_ROLLBACK_SEGS
V$ROLLNAME
V$ROLLSTAT
V$UNDOSTAT
1.13 Tables
1.13.1 Creating tables
- 24 -
Oracle DBA Concise Handbook
DBA_TABLES
DBA_TAB_COLUMNS – all columns of all tables
- 25 -
Oracle DBA Concise Handbook
1.14 Indexes
Bitmap index
- 26 -
Oracle DBA Concise Handbook
ADDRESS VARCHAR2(200),
CITY VARCHAR2(50),
STATE CHAR(2),
COUNTRY VARCHAR2(100),
POSTCODE VARCHAR2(10),
PHONE VARCHAR2(50),
EMAIL VARCHAR2(100),
USERNAME VARCHAR2(20) default USER,
DATESTAMP DATE default SYSDATE
) tablespace SUPERMARKET_DATA
ORAGANIZATION INDEX
OVERFLOW TABLESPACE ovfl_tblsp
INCLUDING address
PCTTHRESHOLD 25
MAPPING TABLE
You can also move index to a different table space using ALTER INDEX
index_name TABLESPACE new_table_space command.
DBA_INDEXES
DBA_IND_COLUMNS
1.15 Constraints
Types of constraints – not null, check, unique, primary key, foreign key
- 27 -
Oracle DBA Concise Handbook
Enable validate – default, existing rows and future rows are checked
Enable novalidate – existing rows not checked but future rows are checked
Disable validate – existing rows checked but future rows are not checked (no
DML is allowed on table)
Disable novalidate – no check done on existing or future rows
- 28 -
Oracle DBA Concise Handbook
DBA_CONSTRAINTS
DBA_CONS_COLUMNS
1.16.1 Profile
1.16.2 Users
- 29 -
Oracle DBA Concise Handbook
1.16.3 Privilege
For object privileges, both grantor and grantee information is stored in data
dictionary; where as for system privilege, only grantee information is stored.
1.16.4 Roles
DBA_USERS
DBA_TS_QUOTA – space assigned to users
V$SESSION – users currently connected to database
- 30 -
Oracle DBA Concise Handbook
DBA_TAB_PRIVS
DBA_COL_PRIVS
DBA_SYS_PRIVS
SESSION_PRIVS
DBA_ROLES
DBA_ROLES_PRIVS
ROLE_ROLE_PRIVS
- 31 -
Oracle DBA Concise Handbook
2.1 Introduction
When instances crashes for any reason (e.g. Power failure) Oracle automatically
recovers when database starts next time.
The most important decision you need to take for backup is to decide whether
the database will run in archive or no archive log mode. Usually production
databases always run in archive log mode.
Ideally, each member of archive log groups should reside in different physical
disks so that if one disk gets corrupt, identical copies can be retrieved from
another disk.
Backup can be either user managed (copying files with OS commands) or server
managed (RMAN – Recovery Manager based). If you use RMAN, you can have
incremental backups (i.e. backing up only changed blocks since last backup).
RMAN is not discussed in this book.
When the database is running in no archive log mode, only cold back up can be
taken. The steps are –
- 32 -
Oracle DBA Concise Handbook
Data file headers don’t get updated until backup ends. Ideally, perform hot
backup when there is less DML is occurring in the database.
In all the following cases, it is assumed that database is running in archive log
mode and backup was already taken.
2.4.1 System table space lost/corrupt
1. STARTUP MOUNT
2. Restore only system table space file
3. If required, relocate file – ALTER DATABASE RENAME file TO new
file
4. RECOVER AUTOMATIC DATABASE (or DATAFILE file name)
5. ALTER DATABASE OPEN
1. STARTUP MOUNT
2. Make data file offline – ALTER DATABASE file name OFFLINE
3. ALTER DATABASE OPEN
4. Restore data file from backup to database location
5. If required, relocate file – ALTER TABLESPACE table space name
OFFLINE IMMEDIATE for issuing check point
6. RECOVER AUTOMATIC TABLESPACE table space name
7. ALTER TABLESPACE table space name ONLINE
1. STARTUP MOUNT
2. ALTER DATABASE CREATE DATAFILE filename with path AS new
filename (only if relocate)
- 33 -
Oracle DBA Concise Handbook
Entire database won’t start. Data file header freezes during backup, so no
checkpoint information is written.
1. STARTUP MOUNT
2. ALTER DATABASE END BACKUP
3. ALTER DATABASE OPEN
1. STARTUP MOUNT
2. Restore all data files (including system, data, index, undo but not control
file or redo log files)
3. RECOVER DATABASE UNTIL TIME ‘dd-mon-yyyy hh24:mi:ss’ (or
CANCEL or CHANGE number)
4. ALTER DATABASE OPEN RESETLOGS
SHUTDOWN
Take full backup of database
Export may be either through conventional path or direct path. In direct path
export, the evaluating buffer is bypassed and makes it faster.
- 34 -
Oracle DBA Concise Handbook
Example of export,
exp system/password file=F:\Database\exp_mkm.dmp owner=mkm rows=y
You can run export/import in interactive mode i.e. it will ask you about
parameters during runtime.
Data pump
From 10g onward, Oracle introduces new utilities EXPDP and IMPDP (as run
from OS command prompt) to fast data loading (export/import). As it uses API,
it is significantly faster than export/import utility. You can even monitor data
pump progress from data dictionary views.
Example:
expdp system/password DIRECTORY=data_pump_dir
DUMPFILE=supermarket.dmp SCHEMAS=mkm
- 35 -
Oracle DBA Concise Handbook
Using SQL Loader, you can load data from text file to Oracle tables.
If you specify DIRECT=Y option, SQL Loader will bypass buffer and save data
directly into data blocks in the disk. It makes data loading very fast however,
this option does not enforce constraints, does not fire insert triggers, does not
allow SQL functions in control file and locks entire table during loading.
A sample control file is shown below (assuming input data file is | delimited).
LOAD DATA
INFILE 'F:\DUMP\CUSTOMER.TXT'
BADFILE 'F:\DUMP\CUSTOMER.BAD'
DISCARDFILE 'F:\DUMP\CUSTOMER.DSC'
APPEND
INTO TABLE CUSTOMER
FIELDS TERMINATED BY "|"
TRAILING NULLCOLS
(
CUSTNO DECIMAL EXTERNAL "sq_cust_no.nextval",
CUSTNAME CHAR,
SEX CHAR,
ADDRESS CHAR,
CITY CHAR,
STATE CHAR,
COUNTRY CHAR,
POSTCODE CHAR,
PHONE CHAR,
EMAIL CHAR,
NOTE CHAR,
DATESTAMP DATE "YYYY-MM-DD HH24:MI:SS”
)
- 36 -
Oracle DBA Concise Handbook
Note for NUMBER columns you specify DECIMAL EXTERNAL and for
VARCHAR2 columns you specify CHAR in SQL Loader control file.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ensel)(PORT =
1521))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = MDB)
(ORACLE_HOME = E:\oracle\ora92)
(SID_NAME = MDB)
)
)
You can manage listener from OS command prompt using LSNRCTL utility.
- 37 -
Oracle DBA Concise Handbook
Oracle Net Manager is a tool using which you can manage most client/server
configuration files.
Most popular name resolution methods are – host naming, local naming (most
common using tnsnames.ora) and Oracle Internet Directory naming.
MDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ensel)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MDB)
)
)
MARKET =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 109.125.257.250)(PORT
= 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MARKET)
)
)
- 38 -
Oracle DBA Concise Handbook
tnsnames.ora file (there may be multiple version in computer). You can verify
this by checking TNS_ADMIN environment variable. Also check whether
client computer can talk to server computer by running “TNSPING server ip
address” command. Or you can use PING SID command as well.
Check sqlnet.ora file and see whether it specifies local naming first. This file
resides in both client and server.
EXECUTE DBMS_LOGMNR_D.BUILD
('dictionary.ora','E:\ORACLE\ORADATA\UNLOAD', OPTIONS =>
DBMS_LOGMNR_D.STORE_IN_FLAT_FILE);
exec dbms_logmnr.add_logfile
('E:\oracle\oradata\MDB\Archive1\ARC00026.001',
dbms_logmnr.new);
exec dbms_logmnr.add_logfile
('E:\oracle\oradata\MDB\Archive1\ARC00027.001',
dbms_logmnr.addfile);
exec dbms_logmnr.add_logfile
('E:\oracle\oradata\MDB\Archive1\ARC00028.001',
dbms_logmnr.addfile);
exec dbms_logmnr.add_logfile
('E:\oracle\oradata\MDB\Archive1\ARC00029.001',
dbms_logmnr.addfile);
- 39 -
Oracle DBA Concise Handbook
Once the redo logs were analyzed, all the DDL (and some DML) statements
applied in the source database will be found in the V$LOGMNR_CONTENTS
view. Important columns of this view are - SQL_UNDO, SQL_REDO,
USERNAME, SCN, TIMESTAMP, COMMIT_TIMESTAMP, TABLESPACE,
SEG_NAME, SEG_TYPE, and OPERATION.
The Log Miner session is closed by executing following command in the same
session.
EXEC DBMS_LOGMNR.END_LOGMNR
After the session is complete, all data in the v$logmnr_contents table are
deleted. Be sure to execute CREATE TABLE my_logmnr AS SELECT ... to
copy the data before analyzing the contents.
Log Miner can potentially be dealing with large amounts of information. There
are several methods you can use to limit the information that is returned to the
V$LOGMNR_CONTENTS view, as well as the speed at which it is returned.
These options are specified when you start LogMiner.
- 40 -
Oracle DBA Concise Handbook
- 41 -
Oracle DBA Concise Handbook
The data files are stored in several disk drives which are connected by cluster
aware storage. By adding multiple instances, we can add and remove and single
Oracle instance without bringing the database down. So, database always
remains available. That is the essence of RAC - high availability.
Any storage (eg. SAN, SCSI etc.) can be used with RAC. However, good I/O
speed is required for scalability of data volume.
RAC supports up to 100 clusters which may be different at hardware level but
must run same operating system.
An Oracle RAC database requires three components - cluster nodes (the servers
or computers running Oracle instances), shared storage (disk drives) and Oracle
Clusterware (software application).
Installing RAC
The first step of working with RAC is to install "Oracle Clusterware" which is
installed via Universal Installer.
- 42 -
Oracle DBA Concise Handbook
Then perform post installation tasks. This ensures that clusterware and database
are installed properly and they are aware of each other.
Administering Clusterware
Oracle Clusterware includes two important components: the voting disk and the
OCR. The voting disk is a file that manages information about node
membership, and the OCR is a file that manages cluster and Oracle RAC
database configuration information.
RAC can be administered via Oracle Enterprise manager. On EM's web console
mode, click on Availability tab to see details of Clusterware. You can click on
Topology tab to see a visual representation of your nodes. The Interconnect tab
shows you info on interfaces. You can also add new instance to clusterware via
EM (under Server tab).
Cache Fusion
Oracle RAC uses Cache Fusion to synchronize the data stored in the buffer
cache of each database instance – i.e. to keep track of which nodes are writing
to which blocks and to ensure that two nodes do not update duplicate copies of
the same block. Since all computers/instances in an RAC access the same
database, the overall system must guarantee the coordination of data changes on
different computers such that whenever a computer queries data it receives the
current version – even if another computer recently modified that data. Oracle
RAC refers to this functionality as Cache Fusion. It involves the ability of RAC
to fuse in-memory data cached physically separately on each computer into a
single global cache. This saves a lot of resource time.
- 43 -
Oracle DBA Concise Handbook
This may be created from last back up taken for the production database and
there after applying archived redo log files on it. This is similar to recovering a
database. However, for stand by database, this recovery is like a continuous
process, because, archived logs (from production database) are continuously
being applied on it to make it sync with production database. However, stand by
database won’t be available for use until recovery is completed.
2.11.2 Logical stand by
Instead of applying archived redo log files, SQL statement is constructed from
log files are being applied to stand by database (similar to Log Miner method).
The database is available for use during application of SQLs.
2.12 Replication
- 44 -
Oracle DBA Concise Handbook
3 Performance Tuning
This file records information and error messages for various database activities.
This file is located at BACKGROUND_DUMP_DEST folder. The name format
is alert_SID.log.
Background process trace files contains session information for process that
created them. These files are available in BACKGROUND_DUMP_DEST
folder. Name format for the trace file is usually SID_PROCESS_nnnn.trc e.g.
mdb_lgwr_1598.trc.
User trace files are found in USER_DUMP_DEST folder. These are created
when error occurs in user’s server process. User tracing can be enabled using
- 45 -
Oracle DBA Concise Handbook
V$SGASTAT
V$EVENT_NAME
V$SYSTEM_EVENT
V$SESSION_EVENT
V$SESSION_WAIT
V$STATNAME
V$SYSSTAT
V$SESSTAT
V$SESSION
V$WAITSTAT
DBA_TABLES
DBA_INDEXES
DBA_STATS
DBA_DATA_FILES
DBA_SEGMENTS
DBA_HISTOGRAMS
Run UTLBSTAT and UTLESTAT to collect all database activities in the given
time period in a single file.
3.3.1 Statspack
- 46 -
Oracle DBA Concise Handbook
Capacity Planner
Performance Manager – observe database performance.
Top Sessions – see which users are consuming most resource
Trace Data Viewer
Lock Monitor
Top SQL – most resource consuming SQLs
Performance Overview – see current performance of database
Oracle Expert – gathers statistics and gives recommendations for tuning
Index Tuning Wizard – identify unused indexes
3.5.1 TKPROF
Example usage
TKPROF ORA_1234.TRC TRACE.TXT SYS=NO
EXPLAIN=MKM/MKM@MDB RECORD=SQL.TXT
To identify SQL statements, which may require tuning, look for statements –
Consuming excess CPU resource
Taking long time to parse, execute and fetch
Reading too many data blocks from disk and too few from SGA
Access many data blocks but return only few rows
- 47 -
Oracle DBA Concise Handbook
Remember that, if you run the above query, you will see the plan in an
indented view. The innermost operations are executed first. If two
operations appear at same level (with same inner level), the top one is
executed first.
Unlike explain plan, auto trace executes the actual SQL statement before
generating the plan.
- 48 -
Oracle DBA Concise Handbook
3.6 Optimizer
Earlier versions of Oracle used Rule Base Optimizer (RBO). But latest versions
use Cost Based Optimizer (CBO) by default.
EXECUTE DBMS_UTILITY.ANALYZE_SCHEMA('MKM','COMPUTE')
To change optimizer mode at statement level, you should use hints using /*+ …
*/.
If statistics exists for any one table or index involved in SQL statement, CBO is
used, otherwise RBO is used.
- 49 -
Oracle DBA Concise Handbook
To reuse a saved execution plan, you can use “plan stability” (in the form of
stored outline) feature or “materialized view”.
Unlike in normal view, materialized view actually stores the data in tables.
EXEC DBMS_MVIEW.REFRESH('schema.mview_name','C');
EXEC DBMS_MVIEW.REFRESH_ALL_DEPENDENT('table_name');
EXEC DBMS_MVIEW.REFERSH_ALL_MVIEWS;
It uses range of column values to determine where the record will be inserted.
- 50 -
Oracle DBA Concise Handbook
It uses range partition and inside it uses hash sub-partitions. Data is physically
stored in sub-partition level.
Note: Any bitmap indexes created on partitioned table must be local (to the
partition).
3.6.4.5 Cluster
A cluster is a group of one or more tables whose data is stored at same place
(physically). This helps faster access of data columns, which are often queried
as joins because Oracle server needs to read less number of physical data
blocks.
- 51 -
Oracle DBA Concise Handbook
Take an example of Transaction and Transaction Detail tables. These two are
linked by foreign key TransId. Now, master table has transaction date but detail
table do not. We want both tables be partitioned by transaction date. In 11g, we
can specify details tables be partitioned based on foreign key reference TransId.
Interval partition is useful when we do not know how many partitions we need
beforehand. In above example, we can specify the table such a way whenever
new month begins, a new partition will be created automatically.
Shared pool consists of library cache and data dictionary cache. Library cache
caches most recently used SQL and PL/SQL statements. Data dictionary cache
caches data dictionary information. Shared pool is managed by a Least Recently
Used algorithm.
Finding a matching SQL statement in shared pool is known as cache hit. For
cache hit to occur, two SQL statements must be exactly same i.e. their ASCII
value equivalent should be same. The aim of tuning shared pool is to maximize
cache hit ratio.
High cache hit ratio indicates that your application users are getting results of
SQL and PL/SQL mostly from memory rather than reading from disk.
GET is referred to parse lock, while PIN is referred to execution time locks.
- 52 -
Oracle DBA Concise Handbook
You can set aside a reserved area in SGA for large PL/SQL packages. This area
is controlled by SHARED_POOL_RESERVED_SIZE parameter.
Determine which packages are loaded into memory from following command
You can “pin” most frequently used PL/SQL code in memory. To do this –
- 53 -
Oracle DBA Concise Handbook
You must have very good knowledge of application to determine which objects
to pin right after instance startup. You can audit PL/SQL packages, triggers,
sequences etc. and find out which objects are most frequently accessed.
It caches most recently accessed data blocks into memory. If data is not found
from cache, it is fetched from disk. It is operated on LRU mechanism (except,
only for full table scan, it is placed on MRU end.)
- 54 -
Oracle DBA Concise Handbook
To get an idea how much you should increase buffer cache size
Set DB_CACHE_ADVICE = ON initialization parameter.
Query V$DB_CACHE_ADVICE view.
Determining which segments to cache in keep and recycle pools, you must have
in depth knowledge of the application.
Oracle recommends you consider caching of segments in keep pool whose total
size is less than 10% of default pool size.
- 55 -
Oracle DBA Concise Handbook
FROM v$buffer_pool_statistics
ORDER BY NAME
Build indexes on foreign key columns of tables that reference a primary key
column in another table.
By default, Oracle runs on dedicated server mode where for each user session
connection, a server process is created on server and a user process is created on
client machine. When number of concurrent users becomes very high, shared
server (known as Multi Threaded Server in earlier versions) is used.
Shared server is useful for these scenarios – many application users, short
application transactions (e.g. railway reservation system, order entry system),
non-continuous transactions etc.
DISPATCHERS = n (0 to 5)
- 56 -
Oracle DBA Concise Handbook
SELECT NAME,
decode(busy+idle,0,0,round((busy/(busy+idle))*100,4)) "busy
rate" FROM v$shared_server WHERE status != 'QUIT'
Additional dispatcher is necessary is busy ratio found from above query is more
than 50%.
Please note that DBA must connect through dedicated server to perform various
DBA activities (e.g. startup/shutdown database).
Large pool in SGA is used for Recovery Manager (RMAN) operations and
parallel query.
Java pool is used to keep session specific Java application code and variables.
Its size is determined by JAVA_POOL_SIZE (default 20M) initialization
parameter and cannot be changed dynamically.
- 57 -
Oracle DBA Concise Handbook
- 58 -
Oracle DBA Concise Handbook
From Oracle 9i, automatic undo management does away manual rollback
segment management. However, you can set a specific rollback segment for
large transaction by this command –
CREATE PRIVATE ROLLBACK SEGMENT rbs STORAGE (INITIAL
1M NEXT 10M) TABLESPACE rbstb
ALTER ROLLBACK SEGMENT rbs ONLINE
SET TRANSACTION USE ROLLBACK SEGMENT rbs
EXEC procedure
ALTER ROLLBACK SEGMENT rbs ONLINE
3.16 Locks
Lock contention occurs when multiple users try to obtain lock on specific object
at the same time. Lock is released only after COMMIT or ROLLBACK
statement.
V$LOCK
V$LOCKED_OBJECT
DBA_WAITERS
DBA_BLOCKERS
To resolve lock contention, avoid coding long transactions and don’t use
restrictive explicit locks. It is always better to let Oracle handle all locks.
You can kill any session using ALTER SYSTEM KILL SESSION ‘sid, serial#’
command.
- 59 -
Oracle DBA Concise Handbook
If server has multiple CPUs, use Oracle’s parallel query, parallel DML, parallel
ANALYZE and parallel index creation features. In multiple CPU machines,
Oracle will itself change many parameters.
You can allocate and manage server resources using Oracle’s Resource
Manager feature (not discussed here).
On Unix, all server processes and background processes are run as separate
executables (you can see them using ps command). However, on Windows, all
those processes run as threads inside ORACLEservicename.EXE process.
From 10g, AWR continuously captures database statistics and derives metrics
from it. This is of immense help during database tuning.
From 10g, ADDM constantly monitors database and in case of any problem, it
will suggest what you should do next. The ADDM findings can be queried from
DBA_ADVISOR% objects on data dictionary. Note that ADDM analysis is
based on AWR snapshots, which have a default frequency of once an hour and a
default retention period of 8 days.
- 60 -
Oracle DBA Concise Handbook
- 61 -
Oracle DBA Concise Handbook
DECLARE
TYPE tEmp IS RECORD (
ENO NUMBER, FNAME VARCHAR2(50), LNAME VARCHAR2(50));
vEmp tEmp;
BEGIN
SELECT id, fname, lname INTO vEmp FROM employee;
END;
You can use %ROWTYPE to specify a variable of table row type. For example,
vEmp employee%ROWTYPE;
DECLARE
TYPE tEmp IS TABLE OF VARCHAR2(50) INDEX BY BINARY_INTEGER;
vEmp tEmp;
BEGIN
vEmp(1) = 'Saikat';
END;
4.3 Cursor
Declaring cursor
- 62 -
Oracle DBA Concise Handbook
Processing cursor
OPEN cursor_name;
FETCH cursor_name INTO variable(s);
CLOSE cursor_name;
Cursor attributes
Using pivot insert, you can create multiple rows of data from single record. Say,
SALES_SOURCE_DATA comes from a non-relational source and it contains
following columns – emp_id, sales_mon, sales_tue, sales_wed, sales_thu and
sales_fri. We like to store this information in SALES_INFO table which has
- 63 -
Oracle DBA Concise Handbook
Oracle now follows ANSI/ISO join syntax (similar to SQL Server). You can
also use earlier versions join syntax. However, new ANSI/ISO standard syntax
is more comprehensive. Here are few examples.
Say we have 2 tables – EMP (eno, ename, dno) and DEPT (dno, dname). To list
all employee names and department names we can now write following query.
We can use LEFT, RIGHT or FULL keywords for outer join. For example, to
list all employees even when some employees may not belong to any
department, we can issue this query.
SELECT E.ENAME, D.DNAME FROM EMP LEFT JOIN DEPT ON (E.DNO =
D.DNO)
This is definitely more intuitive than earlier syntax with “+” operator!
- 64 -
Oracle DBA Concise Handbook
VARCHAR2(3) );
/* case 1 – wrong */
UPDATE INFO1 i1 SET (PHONECODE,CURRENCYCODE) = ( SELECT PHONECODE,
CURRENCYCODE FROM INFO2 i2 WHERE i1.CODE = i2.CODE )
-- Sweden's data becomes null by running this!!
/* case 2 – correct */
UPDATE INFO1 i1 SET (PHONECODE,CURRENCYCODE) = ( SELECT PHONECODE,
CURRENCYCODE FROM INFO2 i2 WHERE i1.CODE = i2.CODE )
WHERE EXISTS ( SELECT 1 FROM INFO2 i22 WHERE i1.CODE = i22.CODE)
-- Sweden's existing data remains correct
Decode – some examples have been provided in chapter “Useful scripts for
DBAs”.
Case – example
SELECT COUNTRY, CONTINENT
CASE CONTINENT WHEN 1 THEN ‘EUROPE’
WHEN 2 THEN ‘ASIA’
WHEN 3 THEN ‘AFRICA’
ELSE ‘OTHER’ END CONTINENT_NAME
FROM COUNTRIES
- 65 -
Oracle DBA Concise Handbook
INSTR (string where to search, string what to search, start position default 1,
what “n-th” occurrence default 1st) is used for searching for pattern inside a
string. Returns the number position where occurrence has been found or 0 if not
found.
/* UNPIVOT */
WITH fly_table AS (
SELECT 'India' "Country",'New Delhi' "Capital" FROM dual UNION
SELECT 'UK','London' FROM dual UNION
SELECT 'USA', 'Washington DC' FROM dual UNION
SELECT 'Germany','Berlin' FROM dual
)
SELECT COL, VALUE FROM (
SELECT * FROM fly_table
)
UNPIVOT INCLUDE NULLS ( VALUE FOR COL IN ("Country","Capital"))
- 66 -
Oracle DBA Concise Handbook
AS
cur INTEGER;
p INTEGER;
stmt VARCHAR2(100);
BEGIN
cur := dbms_sql.open_cursor;
stmt := 'INSERT INTO TEST.EMP VALUES(:no,:name)';
dbms_sql.parse(cur,stmt,dbms_sql.v7);
dbms_sql.bind_variable(cur,':no',pNo);
dbms_sql.bind_variable(cur,':name',pName);
p := dbms_sql.EXECUTE(cur);
COMMIT;
dbms_output.put_line(p);
dbms_sql.close_cursor(cur);
END;
Run the procedure from SQL Plus as EXEC DYNSQL(1,'Saikat');
- 67 -
Oracle DBA Concise Handbook
Now if there is no index on column X in T2, Oracle will perform full table scan
for each record in T1.
Hash join
Oracle will load create an in-memory index (known as hash table) for T2 (i.e.
smaller table)
But even if there is no index on T2.X, Oracle will use the hash table which
works similar to index!
Clearly this is suitable only when T2 is small otherwise [1] hash table may not
fit in memory [2] creation of hash table may involve a long time (then we could
have created the index on T2 in first place!)
- 68 -
Oracle DBA Concise Handbook
If both tables are very big, hash join is not suitable due to memory/time
requirement and nested loop will be slow or will result in full table scan.
In this case, both tables are sorted by Oracle (using temporary table space) by
joining key (X in this case).
The advantage is, when joining two tables, Oracle just needs to scan only a
small part of the table (e.g. as they are sorted, to find a record in T2 when T1.X
= 15 will require Oracle search just from X=10 to X=20 in T2 as it cannot be
beyond this range and so on).
The trade off is, it will take some resource (space/time/memory) to sort the
tables.
- 69 -
Oracle DBA Concise Handbook
By creating external tables, you can run SQL statements on simple delimited
text files! However, external tables are read only i.e. you can’t update their data
using SQL (you need to modify them in text editor).
To create an external table, first you need to create a folder in your hard disk
where you will place the text files.
The user, who will access external table, should have CREATE ANY
DIRECTORY system privilege.
- 70 -
Oracle DBA Concise Handbook
5 DBMS Packages
5.1 DBMS_JOB
BEGIN
SYS.DBMS_JOB.SUBMIT(
JOB => :JOB,
WHAT => 'BEGIN UPDATE_ALL_TRANS_PRICE; END;',
NEXT_DATE => TO_DATE('11-06-2004 09:54:15', 'DD-MM-YYYY
HH24:MI:SS'),
INTERVAL => 'SYSDATE+15/1440');
COMMIT;
END;
5.2 UTL_FILE
CURSOR cTable IS
SELECT * FROM category;
f utl_file.file_type;
buf VARCHAR2(200);
BEGIN
f:=UTL_FILE.FOPEN('E:\ORACLE\ORADATA\UNLOAD','CATEGORY.TXT','w
');
FOR i IN cTable LOOP
buf:=i.CategoryNo || '|' || i.Description || '|' ||
i.ParentCategoryNo;
UTL_FILE.PUT_LINE(f,buf);
END LOOP;
UTL_FILE.FCLOSE(f);
DBMS_OUTPUT.PUT_LINE('TABLE UNLOADED');
EXCEPTION
WHEN OTHERS THEN
- 71 -
Oracle DBA Concise Handbook
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
/
- 72 -
Oracle DBA Concise Handbook
SELECT
D.TABLE_NAME "Table name",
D.CONSTRAINT_NAME "Constraint name",
DECODE(D.CONSTRAINT_TYPE,
'P','Primary Key',
'R','Foreign Key',
'C','Check/Not Null',
'U','Unique',
'V','View Cons') "Type",
D.SEARCH_CONDITION "Check Condition",
P.TABLE_NAME "Ref Table name",
P.CONSTRAINT_NAME "Ref by",
M.COLUMN_NAME "Ref col",
M.POSITION "Position",
P.OWNER "Ref owner"
FROM
DBA_CONSTRAINTS D
LEFT JOIN
DBA_CONSTRAINTS P
ON (D.R_OWNER=P.OWNER AND
D.R_CONSTRAINT_NAME=P.CONSTRAINT_NAME)
LEFT JOIN
DBA_CONS_COLUMNS M
ON (D.CONSTRAINT_NAME=M.CONSTRAINT_NAME)
WHERE
D.TABLE_NAME
IN (
SELECT TABLE_NAME FROM DBA_TABLES WHERE
OWNER=UPPER('mkm')
UNION ALL
SELECT VIEW_NAME FROM DBA_VIEWS WHERE OWNER=UPPER('mkm')
)
ORDER BY 1,2,3
SELECT
D.OWNER,D.SEGMENT_NAME,D.SEGMENT_TYPE,D.TABLESPACE_NAME,
D.HEADER_FILE,V.NAME
FROM
Dba_Segments D
- 73 -
Oracle DBA Concise Handbook
SELECT
SID,
SERIAL#,
v.schemaname,
DECODE(COMMAND
,0,'None'
,2,'Insert'
,3,'Select'
,6,'Update'
,7,'Delete'
,8,'Drop'
,26,'Lock Table'
,44,'Commit'
,45,'Rollback'
,47,'PL/SQL Execute'
,'Other') command
FROM V$SESSION v
- 74 -
Oracle DBA Concise Handbook
FROM (
(SELECT f.tablespace_name, ROUND(SUM(f.bytes/(1024*1024)),2)
"Free MB" FROM dba_free_space f
GROUP BY f.tablespace_name) a
RIGHT JOIN
(SELECT d.tablespace_name, ROUND(SUM(d.bytes/(1024*1024)),2)
"Total MB" FROM dba_data_files d
GROUP BY d.tablespace_name) b
ON a.tablespace_name = b.tablespace_name
)
ORDER BY 1
- 75 -
Oracle DBA Concise Handbook
Which are not covered in this book so far. Any feature which is introduced in
10g, is also available in 11g with usually more options.
You already have flashback query option in Oracle 9i where you can query
snapshot of old data from undo table space. But in 10g, you can examine how
values changed between two time points.
Rollback monitoring
In 9i, you can’t tell easily how much time it is going to take to rollback a large
transaction (until it is complete, the locks acquired by the transaction won’t be
released). In 10g you can simply get this vital information from
V$SESSION_LONGOPS view.
Flashback table
In 9i, to restore a dropped table you need to use import from back up or do
incomplete recovery. In 10g, when a table is dropped, it goes to Oracle’s
Recycle Bin and you can easily restore it from there! You can run following
command from SQL Plus.
- 76 -
Oracle DBA Concise Handbook
Several enhancement has been made to SQL Plus like prompting, improved file
manipulations, fast DUAL optimization plan etc.
In 9i, disk storage consideration (like RAID, stripping, logical grouping etc.)
was done manually. From 10g it can be done automatically with the help of
ASM.
RMAN improvement
Auditing improvements
Now auditing can be performed at very detail level (FGA – fine grained audit).
In 10g, auditing will show you what user made exactly what changes to data.
Wait interface
Data dictionary views now show more information regarding on user wait
events, which will help to diagnose wait problems better.
Model clause
Using MODEL clause in SQL, you can treat multidimensional data as an array
in memory where you can apply spreadsheet like calculations!
Its architecture has been changed in 10g. It’s now installed as an HTTP server
(instead of as a client tool in 9i). So, you will use it inside browser! Moreover
lots of new features have been added. See section 1.6 for more information.
- 77 -
Oracle DBA Concise Handbook
VPD was also in 8i and 9i. But in 10g, it has improved to support a variety of
requirements, such as masking columns selectively based on the policy and
applying the policy only when certain columns are accessed. VPD has not been
discussed so far in this book. It is a method to implement security at finer grain.
For example, if you want to implement that logged on user will only see his
own records in database (e.g. seeing only his salary information from salary
table), VPD can be set up in such a way that “where username = USER” will be
automatically added to SQLs.
Segment management
In 9i, transportable table spaces can be plugged in to other databases only if they
run on same platform. In 10g, they can be plugged to database even running on
different platforms. This is very helpful for data movement across different
systems. Another improvement is that, data can be unloaded from tables in very
fast manner (in non-text format, though) but the unloaded file, again, can be
used across platforms.
The space allocation for DB buffer cache, shared pool, large pool and Java pool
can be set to manage automatically and dynamically as and when required (i.e.
depending on the database workload)!
Scheduler
Usually dbms_job can be used only to run PL/SQL programs. However, the
newly introduced dbms_scheduler can even run OS commands at specified
time/interval.
Database replay
Starting from 11g, you now have option of capturing work load from a
production database and replay that on test database to simulate live conditions.
- 78 -
Oracle DBA Concise Handbook
Oracle defines grid computing like this: with grid computing, groups of
independent, modular hardware and software components can be connected and
rejoined on demand to meet the changing needs of businesses.
Now come to the present days. We are gathering data like never before! Besides
RDBMS, we now have lots of different stuffs like OLAP (Business
Intelligence/Data Warehouse etc.), OLTP (transactional data), BPEL (Business
Process Execution Language), Web services (using XML), OWB (Oracle
Warehouse Builder) etc.
The grid is collection of all these - i.e. different applications and data which
speak with one another.
There's another aspect of grid. Let us take Oracle Real Application Cluster or
RAC. Here multiple instances of database are inter-connected to safeguard
- 79 -
Oracle DBA Concise Handbook
7.2 What are Oracle Fusion Middleware (OFM) and Service Oriented
Architecture (SOA)?
If you are not sure about what are these things and try to have a look at Oracle's
website, there is a good chance that you might find yourself confused.
That's quite expected. Oracle's website is for marketing their product. It's not
their interest to describe their products in a way that people think it is there is no
magic about it!
This includes Oracle's Developer suite (Forms & Reports), Java related tools,
web logic server, content management etc. OFM depends on open standards
such as BPEL, SOAP, XML and JMS.
What is SOA?
The main essence of SOA is that applications will talk with each other in a
language (i.e. data format, process steps) which is understood by all others
applications communicating with.
SOA helps business to move, change, partner and re-invent itself with ease and
grace.
SOA extends idea of reuse not only to web services but also with business
services.
- 80 -
Oracle DBA Concise Handbook
Web service
Example, you throw a postcode to Yahoo Geo-coder and it gives you back
latitude, longitude of that post code.
You ask for price of particular item to a website, it supplies you the price.
Usually, web service results are returned in XML format to ensure universal
compatibility.
In SOA segment, you will often hear the term Orchestration. What does it
mean?
If you seen an orchestra, you know that conductor just draws some invisible
drawings in mid air by moving his magic wand from one side to another.
However, musicians can decipher his rhythm and plays their instruments so that
every one plays same tune at same pace.
Orchestration in SOA has similar meaning. It ensures that all applications under
SOA, know how to be in sync with other applications in the group.
BPEL is a tool, using which you can draw how data moves from one application
to another. For those who have not used it, it is like a Visio flow chart diagram
editor. But, when you draw objects in BPEL, you tell them what to do. You
instruct them where to read data from, how to process it and where to send
output after processing finished. So, basically it is a graphical tool to define
business process. Without BPEL, the whole process will look like thousands of
lines of PL/SQL (or Java or C++ or whatever) codes!
Behind the scene BPEL still writes codes - but it just make simpler (!) for any
business user to understand and define the process. Now whether that is good or
bad is debatable – I am just outlining the concept here.
So, BPEL works to integrate several applications. BPEL usually follows XML
standard as interface to several components.
- 81 -
Oracle DBA Concise Handbook
Let us take a bigger example. Your supplier sends you a file which contains all
the products, quantities and unit price you ordered for. You need to update your
inventory accordingly. Now assume that your supplier quoted the price in € but
you need to put that in £ in your database. Using absolute minimum technology,
you need to write a small program to convert € to £ while loading that data to
your system. But if you are using BPEL, you can visually draw the program!
- 82 -
Oracle DBA Concise Handbook
Answers are not provided. Some questions are basic and straightforward. Some
questions are open ended. If you cover OCP curriculum, you will be able to
answer most questions. These questions are for DBAs with 3 – 8 years of
experience.
Please note that in most DBA interviews, besides core DBA questions,
candidates are usually asked some questions about the operating system (say
Unix) as well.
8.2.1 Set 1
1. Explain the difference between a hot backup and a cold backup and the
benefits associated with each.
2. You have just had to restore from backup and do not have any control
files. How would you go about bringing up this database?
- 83 -
Oracle DBA Concise Handbook
- 84 -
Oracle DBA Concise Handbook
8.2.2 Set 2
- 85 -
Oracle DBA Concise Handbook
16. Explain what a bitmapped index is, what its applications would be, and
why it's useful.
17. Explain what an Oracle snapshot is.
18. Have you heard about Tuxedo, Encina, CICS?
19. How can one implicitly disconnect a user from the database, who is idle
for a long time? (Using Profiles)
20. Is it possible that there could be performance degradation due to so many
indexes? When and how?
21. Questions were asked about parameters in export, like: consistent = y,
(what is the purpose of it)?
22. There are 100 data files, numbered from 1 to 100. File number 10 is
deleted and it has 500 MB of data. The database is working in No-
Archive log mode. How can the database be recovered?
23. There are about a 10,000 records in a table. User 1 runs a query, which is
doing a full-table scan. While doing the full table scan, user 2 changes
some value x to y using a DML statement in record. What does the 1st
user see (x or y)? If x, then where is the value stored? (Rollback
Segments).
24. What RDBMS objects are required before you can create a table?
25. What are the contents of a Control File?
26. What are the different data structures used for indexes?
27. What are the types of recovery one can perform?
28. What can you do with an alias that you cannot do with a synonym?
29. What is Normalization?
30. What is a correlation name and explain the usage?
31. What is a cursor?
32. What is a foreign key?
33. What is a join? Explain outer join with an example?
34. What is a page in RDBMS?
35. What is a partitioned table?
36. What is a stored procedure? Why there are required?
37. What is a sub query?
38. What is a synonym?
39. What is a view?
40. What is commit and rollback?
41. What is distributed transaction processing?
42. What is logging in a RDBMS?
43. What is primary key?
44. What is query execution plan?
45. What is query optimizer?
46. What is referential integrity?
47. What is the SQL statement necessary to delete a user named "Joe" and
everything that he owns in a database?
- 86 -
Oracle DBA Concise Handbook
8.2.3 Set 3
- 87 -
Oracle DBA Concise Handbook
- 88 -
Oracle DBA Concise Handbook
- 89 -
Oracle DBA Concise Handbook
- 90 -
Oracle DBA Concise Handbook
9 References
- 91 -
Oracle DBA Concise Handbook
SGA
Control file –
synchronization information
for all Oracle files Data files – System &
Sysaux table space,
Undo table space,
Application data table
spaces etc.
Parameter file
(Read when
database starts)
- 92 -