Professional Documents
Culture Documents
Oracle Technical Interview Questions For An Oracle DBA
Oracle Technical Interview Questions For An Oracle DBA
The listener is a process running on a node that listenes for incoming connections on behlf of a database or a
number of databases. The following are the characteristics of a listener:
When an instance is started, Initialization parameters about the listener are read from the init.ora file by which
PMON registers information with the listener. If a listener is not up when the instance starts, PMON will not
register information with the listener. PMON will continue attempting to contact the listener. The listener will
reject any connections made to an unregistered service.
The listener.ora file
The listener.ora file is used to configure the listener for static service registration. The listener.ora file must
reside on the machine or node on which the listener is to reside.
The listener.ora file contains configuration information for the following:
e.g.
LISTENER =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP)(Host=stc-sun02)(Port=1521))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /home/oracle)
(GLOBAL_DBNAME = ORCL.us.oracle.com)
(SID_NAME = ORCL)
)
START [ listener_name]
STOP [listener_name]
LSNRCTL Commands
Command
CHANGE_PASSWORD
EXIT
HELP
QUIT
RELOAD
SAVE_CONFIG
SERVICES
Description
Dynamically changes the encrypted password of a listener.
Quits the LSNRCTL utility
Provides the list of all available LSNRCTL commands
Provides the functionality of the EXIT command
Shuts down everything except listener addresses and rereads the
listener.ora file. You use this command to add or change services without
actually stopping the listener.
Creates a backup of your listener configuration file (called listener.bak)
and updates the listener.ora file itself to reflect any changes
Provides detailed information about the services the listener listens for
SET parameter
SHOW parameter
SET and SHOW Modifiers
Command
SET CONNECT_TIMEOUT
SET CURRENT_LISTENER
SET LOG_DIRECTORY
SET LOG_FILE
SET LOG_STATUS
SET PASSWORD
SET SAVE_CONFIG_ON_STOP
SET STARTUP_WAITTIME
SET TRC_DIRECTORY
SET TRC_FILE
SET TRC_LEVEL
Description
Determines the amount of time the listener waits for a valid
connection request after a connection has been started
Sets or shows parameters when multiple listeners are used
Sets a nondefault location for the log file or to return the location
to the default.
Sets a nondefault name for the log file.
Turns listener logging on or off
Changes the password sent from the LSNRCTL utility to the
listener process for authentication purpose only.
Saves any changes made by the LSNRCTL SET command
permanently if the parameter is on. All parameters are saved right
before the listener exits.
Sets the amount of time the listener sleeps before responding to
a START command
Sets a nondefault location for the trace file or to return the
location to the default
Sets a nondefault name for the trace file
Turns on tracing for the listener
)
(CONNECT_DATA=
(SID=HDEV1)
)
)
FNDFS_CIDCSCFSHRDEV1=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=cidcscfshrdev1.cidc.cummins.com)(PORT=4802))
(CONNECT_DATA=
(SID=FNDFS)
)
)
FNDFS_CIDCSCFSHRDEV1.cidc.cummins.com=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=cidcscfshrdev1.cidc.cummins.com)(PORT=4802))
(CONNECT_DATA=
(SID=FNDFS)
)
)
FNDFS_HDEV1_CIDCSCFSHRDEV1=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=cidcscfshrdev1.cidc.cummins.com)(PORT=4802))
(CONNECT_DATA=
(SID=FNDFS)
)
)
FNDFS_HDEV1_CIDCSCFSHRDEV1.cidc.cummins.com=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=cidcscfshrdev1.cidc.cummins.com)(PORT=4802))
(CONNECT_DATA=
(SID=FNDFS)
)
)
FNDSM_CIDCSCFSHRDEV1_HDEV1=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=cidcscfshrdev1.cidc.cummins.com)(PORT=4802))
(CONNECT_DATA=
(SID=FNDSM)
)
)
FNDSM_CIDCSCFSHRDEV1.cidc.cummins.com_HDEV1=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=cidcscfshrdev1.cidc.cummins.com)(PORT=4802))
(CONNECT_DATA=
(SID=FNDSM)
)
)
Rep60_HDEV1,Rep60_HDEV1.world=(ADDRESS=(PROTOCOL=tcp)(HOST=cidcscfshrdev1)(PORT=4803))
IFILE=/u02/app/applmgr/HDEV1/8.0.6/network/admin/HDEV1/HDEV1_ifile.ora
SID_LIST_APPS_HDEV1 =
(SID_LIST =
( SID_DESC = ( SID_NAME = FNDSM )
( ORACLE_HOME = /u02/app/applmgr/HDEV1/8.0.6 )
( PROGRAM = /u02/app/applmgr/HDEV1/11i/fnd/11.5.0/bin/FNDSM )
( envs='MYAPPSORA=/u02/app/applmgr/HDEV1/11i/APPSHDEV1.env,PATH=/usr/bin:/usr/ccs/bin:/bin,FNDSM_SCRIPT=/u02/app/appl
mgr/HDEV1/common/admin/scripts/HDEV1/gsmstart.sh' )
)
( SID_DESC = ( SID_NAME = FNDFS )
( ORACLE_HOME = /u02/app/applmgr/HDEV1/8.0.6 )
( PROGRAM = /u02/app/applmgr/HDEV1/11i/fnd/11.5.0/bin/FNDFS )
( envs='EPC_DISABLED=TRUE,NLS_LANG=American_America.UTF8,LD_LIBRARY_PATH=/usr/dt/lib:/usr/openwin/lib:/u02/app/appl
mgr/HDEV1/8.0.6/lib,SHLIB_PATH=/usr/lib:/usr/dt/lib:/usr/openwin/lib:/u02/app/applmgr/HDEV1/8.0.6/lib,LIBPATH=/usr/dt/lib:/usr/openw
in/lib:/u02/app/applmgr/HDEV1/8.0.6/lib,APPLFSTT=HDEV1_FO;HDEV1_BALANCE;HDEV1;HDEV1_806_BALANCE,APPLFSWD=/u0
2/app/applmgr/HDEV1/11i/admin;/u02/app/applmgr/HDEV1/temp;/u02/app/applmgr/HDEV1/common/html/oam/nonUix/launchMode/rest
ricted' )
)
)
# Listener general parameters
STARTUP_WAIT_TIME_APPS_HDEV1 = 0
CONNECT_TIMEOUT_APPS_HDEV1 = 10
TRACE_LEVEL_APPS_HDEV1 = OFF
LOG_DIRECTORY_APPS_HDEV1 = /u02/app/applmgr/HDEV1/8.0.6/network/admin
LOG_FILE_APPS_HDEV1 = APPS_HDEV1
TRACE_DIRECTORY_APPS_HDEV1 = /u02/app/applmgr/HDEV1/8.0.6/network/admin
TRACE_FILE_APPS_HDEV1 = APPS_HDEV1
ADMIN_RESTRICTIONS_APPS_HDEV1 = OFF
IFILE = /u02/app/applmgr/HDEV1/8.0.6/network/admin/HDEV1/HDEV1_listener_ifile.ora
HDEV1_listener_ifile.ora
CHN1 = (DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=cidcscfshrdev1)(PORT=4901))
(CONNECT_DATA=(SID=CHN1))
)
HGOLD=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=ftdcscfshrtst1.ftdc.cummins.com)(PORT=4701))
(CONNECT_DATA=
(SID=HGOLD)
)
)
#HPRD3=
#
(DESCRIPTION=
#
(ADDRESS=(PROTOCOL=tcp)(HOST=cidcscfshrprd1.cidc.cummins.com)(PORT=6801))
#
(CONNECT_DATA=
#
(SID=HPRD3)
#
)
#
)
#
#HPXY2=
#
(DESCRIPTION=
#
(ADDRESS=(PROTOCOL=tcp)(HOST=ftdcscfshrprx1.ftdc.cummins.com)(PORT=5401))
#
(CONNECT_DATA=
#
(SID=HPXY2)
#
)
#
)
#
CILCST_TST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 160.95.215.178)(PORT = 1561))
(CONNECT_DATA = (SERVICE_NAME = CSTTST))
)
If the load on the dispatcher processes is consitently high, start additional dispatcher processes to route
user requests without waiting. You may start new dispatchers until the number of dispatchers equals
MAX_DISPATCHER.
The load on the dispatchers can be monitored using the data dictionary views V$CIRCUIT and
V$DISPATCHER
In contrast, if the loan on dispatchers is consistently low, reduce the number of dispatchers
This view contains information about virtual circuits which are user
connections to the database through dispatchers and servers
This view contains information on the shared server processes
This view provides information on the dispatcher processes
This view contains information for tuning the shared server
processes
This view contains information on request and response queues
This view lists session information for each current session
Oracle Instance
An oracle instance consists of memory areas (mainly system global area (SGA) and background processes,
namely PMON, SMON, DBWn, LGWR, and CKPT. An instance is created during the nomount stage of the
database startup after the parameter file has been read. If any of these processes terminate, the instance shuts
down.
Memory structures
Type
Description
Database buffer cache Memory area used to store blocks read from data files. Data is read into the
blocks by server processes and written out by DBWn asynchronously.
Log Buffer
Memory containing before and after image copies of changed data to be
written to the redo logs
Large pool
An optional area in the SGA that provides large memory allocations for
backup and restore operations, I/o server processes, and session memory
for the shared server and oracle XA.
Shared pool
Stores parsed versions of SQL statements, PL/SQL procedures, and data
dictionary information
Background Processes
Type
Database writer
(DBWn)
Log Writer (LGWR)
System Monitor
(SMON)
Process Monitor
(PMON)
Checkpoint (CKPT)
Archiver (ARCn)
(Optional)
Description
Writes dirty buffers from the data buffer cache to the data files. This activity is
asynchronous.
Writes data from the redo log buffer to the redo log files
Performs automatic instance recovery. Recovers space in temporary
segments when they are no longer in use. Merges contiguous areas of free
space depending on parameters that are set.
Cleans up the connections/server process dedicated to an abnormally
terminated user process. Performs rollback and releases the resources held
by the failed process.
Synchronizes the headers of the data files and control files with the current
redo log and checkpoint numbers.
A process that automatically copies redo logs that have been marked for
archiving
Description
Physical storage of data. At lease one file
is required per database. This file stores
the system tablespace
Contain before and after image copies of
changed data, for recovery purposes. At
least two groups are required
Record the status of the database,
physical structure, and RMAN meta data
Store parameters required for instance
startup
Store persistent parameters required for
instance startup
Type
Binary
Binary
Binary
Binary
Text
Binary
Instance
User
Proces
s
Serverr
Proces
s PGA
SGA
Java pool
Large pool
Database Buffer
Cache
SMON
DBWn
Password
file
Data
Dict.
Cache
PMON
Datafile1
Parameter
file
Shared
SQL and
PL/SQL
CKP
T
Control
File
LGW
R
Redo Log
file 1
ARCn
Archived
Log Files
Datafile2
Redo Log
file 2
Datafile3
Database
Description
V$SGA
Queries the size of the instance for the shared pool, log buffer, data buffer cache
and fixed memory sizes (operating system-dependent)
Queries the status of the instance, such as the instance mode, instance name,
startup time, and host name
Queries the background and server processes created for the instance
Queries the background processes created for the instance
Lists status and recovery information about the database. It includes information
V$INSTANCE
V$PROCESS
V$BGPROCESS
V$DATABASE
V$DATAFILE
on the database name, the unique database identifier, the creation data, the
control file creation date and time, the last database checkpoint, and other
information
Lists the location and names of the data files that are contained in the database. It
includes information relating to the file number and name, creation date, status
(online or offline), enabled (read-only, read-write), last data file checkpoint, size,
and other information
Large Pool
Can be configured as separate memory area in the SGA to be used for:
Oracle backup and restore operations
I/O server processes
Session memory for the shared servers
Is sized by the LARGE_POOL_SIZE parameter
Minimum 300K
SELECT * FROM v$sgastat
WHERE pool = large pool;
Function of the LGWR Background process
The log writer LGWR) writes redo entries from the redo log buffer to the redo log files as follows:
Location and status of backups are recorded by the Recovery Manager utility.
Current log sequence number is recorded when log switches occur.
Checkpoint information is recorded as checkpoints are made.
3. When you start an Oracle DB which file is accessed first?
Answer : Reading the initialization file from $ORACLE_HOME/dbs in the following order:
First spfileSID.ora. If not found then
spfile.ora
initSID.ora
4. What is the Job of SMON, PMON processes?
Answer : The system monitor process (SMON) performs recovery, if necessary, at instance startup. SMON
is also responsible for cleaning up temporary segments that are no longer in use and for coalescing contiguous
free extents within dictionary managed tablespaces. If any terminated transactions were skipped during
instance recovery because of file-read or offline errors, SMON recovers them when the tablespace or file is
brought back online. SMON checks regularly to see whether it is needed. Other processes can call SMON if
they detect a need for it.
With Real Application Clusters, the SMON process of one instance can perform instance recovery for a failed
CPU or instance
The process monitor (PMON) performs process recovery when a user process fails. PMON is responsible for
cleaning up the database buffer cache and freeing resources that the user process was using. For example, it
resets the status of the active transaction table, releases locks, and removes the process ID from the list of
active processes.
PMON periodically checks the status of dispatcher and server processes, and restarts any that have stopped
running (but not any that Oracle has terminated intentionally). PMON also registers information about the
instance and dispatcher processes with the network listener.
Like SMON, PMON checks regularly to see whether it is needed and can be called if another process detects
the need for it.
5. What is Instance Recovery?
Answer : When an Oracle instance fails, Oracle performs an instance recovery when the associated database
is re-started. Instance recovery occurs in two steps:
Cache recovery: Changes being made to a database are recorded in the database buffer cache. These
changes are also recorded in online redo log files simultaneously. When there are enough data in the database
buffer cache, they are written to data files. If an Oracle instance fails before the data in the database buffer
cache are written to data files, Oracle uses the data recorded in the online redo log files to recover the lost data
when the associated database is re-started. This process is called cache recovery.
Transaction recovery: When a transaction modifies data in a database, the before image of the modified
data is stored in an undo segment. The data stored in the undo segment is used to restore the original values
in case a transaction is rolled back. At the time of an instance failure, the database may have uncommitted
transactions. It is possible that changes made by these uncommitted transactions have gotten saved in data
files. To maintain read consistency, Oracle rolls back all uncommitted transactions when the associated
database is re-started. Oracle uses
the undo data stored in undo segments to accomplish this. This process is called transaction recovery.
6. What is written in Redo Log Files?
Answer : Each Oracle database has a redo log. This redo log records all changes made in datafiles.
7. How do you control number of Datafiles one can have in an Oracle database?
8. How many Maximum Datafiles can there be in an Oracle Database?
9. What is a Tablespace?
Answer : A tablespace is a logical storage unit within an Oracle database. It is logical because a tablespace is
not visible in the file system of the machine on which the database resides. A tablespace, in turn, consists of at
least one datafile which, in turn, are physically located in the file system of the server.
Depends on what you specified for MAXLOGFILES during database creation (manually) or what you specified
for "Maximum no. of redo log files" with DBCA
19. What is difference between PFile and SPFile?
A PFILE is a static, client-side text file that must be updated with a standard text editor like "notepad" or "vi".
This file normally reside on the server, however, you need a local copy if you want to start Oracle from a remote
machine. DBA's commonly refer to this file as the INIT.ORA file.
An SPFILE (Server Parameter File), on the other hand, is a persistent server-side binary file that can only be
modified with the "ALTER SYSTEM SET" command. This means you no longer need a local copy of the pfile
to start the database from a remote machine. Editing an SPFILE will corrupt it, and you will not be able to start
your database anymore.
20. What is PGA_AGGREGRATE_TARGET parameter?
21. Large Pool is used for what?
An optional area in the SGA that provides large memory allocations for backup and restore operatins, I/O server
processes, and session memory for the shared server.
22. What is PCT Increase setting?
The percent of increase in extent size after NEXT extent and thereafter.
23. What is PCTFREE and PCTUSED Setting?
PCTFREE for a data segment specifies the percentage of space in each data block reserved for growth resulting
from updates to rows in the block. The default for PCTFREE is 10%.
PCTUSED for a data segment represents the minimum percentage of used space that the oracle server tries to
maintain for each data block of the table. A block is put back on the free list when its used space falls below
PCTUSED.
24. What is Row Migration and Row Chaining?
A migrated row is a row that was moved to another block due to an update making it too large to fit on its
original block with the other rows there. We cannot just "move" the row -- we have lots of indexes pointing to
the original block. We therefore leave behind a forwarding address on the original block and migrate the
updated row to a new block. now, when you access that row, we discover it is not really there -- it is migrated
and we read the other block to get it.
A chained row is a row that is too large to fit on a single block. If you have a 2k blocksize but your row size is
4k, we will use 3 blocks to store that row in pieces. Any table with a long/long raw will have chained rows.
Any table whose rowsize exceeds the blocksize will have chained rows. Any table with more then 255 columns
will have chained rows (we break really wide tables up).
25. What is 01555 - Snapshot Too Old error and how do you avoid it?
26. What is a Locally Managed Tablespace?
27. Can you audit SELECT statements?
28. What does DBMS_FGA package do?
29. What is Cost Based Optimization?
30. How often you should collect statistics for a table?
31. How do you collect statistics for a table, schema and Database?
32. Can you make collection of Statistics for tables automatic?
33. On which columns you should create Indexes?
34. What type of Indexes are available in Oracle?
35. What is B-Tree Index?
36. A table is having few rows, should you create indexes on this table?
37. A Column is having many repeated values which type of index you should create on this column, if you have
to?
38. When should you rebuilt indexes?
39. Can you built indexes online?
27. You loss one datafile and it does not contain important objects. The important objects are there in other
datafiles which are intact. How do you proceed in this situation?
28. You lost some datafiles and you don't have any full backup and the database was running in
NOARCHIVELOG mode. What you can do now?
29. How do you recover from the loss of datafile if the DB is running in ARCHIVELOG mode?
30. You loss one datafile and DB is running in ARCHIVELOG mode. You have full database backup of 1 week
old and partial backup of this datafile which is just 1 day old. From which backup should you restore this file?
31. You loss controlfile how do you recover from this?
32. The current logfile gets damaged. What you can do now?
33. What is a Complete Recovery?
34. What is Cancel Based, Time based and Change Based Recovery?
35. Some user has accidentally dropped one table and you realize this after two days. Can you recover this table
if the DB is running in ARCHIVELOG mode?
36. Do you have to restore Datafiles manually from backups if you are doing recovery using RMAN?
37. A database is running in ARCHIVELOG mode since last one month. A datafile is added to the database last
week. Many objects are created in this datafile. After one week this datafile gets damaged before you can take
any backup. Now can you recover this datafile when you don't have any backups?
38. How do you recover from the loss of a controlfile if you have backup of controlfile?
39. Only some blocks are damaged in a datafile. Can you just recover these blocks if you are using RMAN?
40. Some datafiles were there on a secondary disk and that disk has become damaged and it will take some days
to get a new disk. How will you recover from this situation?
41. Have you faced any emergency situation. Tell us how you resolved it?
42. At one time you lost parameter file accidentally and you don't have any backup. How you will recreate a
new parameter file with the parameters set to previous values.
15. What is Consistent Backup?
A Consistent backup is one in which the files being backed up contain all changes upto the same system
change number (SCN)
16. What is fractured Block?
Because the database continues writing to the file during an online backup, there is the possibility of backing
up inconsistent data within a block. For example, assume that either RMAN or an operating system utility reads
the block while database writer is in the middle of updating the block. In this case, RMAN or the copy utility
could read the old data in the top half of the block and the new data in the bottom top half of the block. The
block is a fractured block, meaning that the data in this block is not consistent.
17. What are the steps to performing complete recovery on the whole database?
18. What are the steps to performing complete recovery on a tablespace or datafile?