Beruflich Dokumente
Kultur Dokumente
Share
More
Next Blog
Page 1 of 7
Create Blog
Sign In
Followers
Blog Archive
Here is the Collection and Answer to some Interesting ORACLE DBA Interview Questions
1. How many memory layers are in the shared pool?
Ans: The shared pool portion of the SGA contains three major areas: library cache(contains parsed
sql statements,cursor information,execution plans), dictionary cache (contains cache -user account
information,priveleges information,datafile,segment and extent information), buffers for parallel
execution messages, and control structure.
2. How do you find out from the RMAN catalog if a particular archive log has been backed-up?
Ans: list archivelog all;
3. How can you tell how much space is left on a given file system and how much space each of the
file systems subdirectories take-up?
Ans: df -kh and du-sh
4. Define the SGA and:
i) How you would configure SGA for a mid-sized OLTP environment?
ii) What is involved in tuning the SGA?
Ans: SGA: The System Global Area (SGA) is a group of shared memory areas that are dedicated
to an Oracle instance (an instance is your database programs and RAM). All Oracle processes
use the SGA to hold information. The SGA is used to store incoming data (the data buffers as
defined by the db_cache_size parameter), and internal control information that is needed by the
database. You control the amount of memory to be allocated to the SGA by setting some of the
Oracle initialization parameters. These might include db_cache_size, shared_pool_size and
log_buffer.
i) 40% of RAM can be used for sizing SGA rest is reserved for OS and others in 64 bit machine and
in 32 bit machine max SGA configured can be 1.5GB only.
ii) Check the statspack report. Check hit ratio of Data buffer. If it is less than 90%, then we need to
increase the Data buffer. Check hit ratio of Shared pool. If it is less than 95%, then we need to
increase the Shared pool. Check log buffer. If redo buffer allocation retries/redo entries is greater
than 1%, then we need to increase log_buffer.
2012 (20)
August (1)
April (19)
Oracle Database Creation: A Manual
Approach
Oracle Data-guard Issues - 'APPLIED'Column not up...
Silent Installation: Oracle 10g
Basics of Oracle Installation- Oracle10g:
A Case S...
Basics of Oracle Installation- Oracle10g:
A Case S...
Basic Oracle Installation: Oracle10g :
Case Study ...
Basics of Oracle Installation: Oracle10g A CASE ...
Alter tablespace ...... Begin Backup/End
Backup
Offline Backups Using RMAN
Active Datagaurd in ORACLE 10g
Difference Between Archive, Redo and
Undo Logs.
Oracle Streams
Snapshot Standby Database
Automatic Memory Management in
Oracle 11g
Collection of Most Common DBA
Interview Questions
Logical Structures in Database
Physical structures of Database
5. What is the cache hit ratio, what impact does it have on performance of an Oracle database and
what is involved in tuning it?
Ans:
Buffer cache hit ratio: It calculates how often a requested block has been found in the buffer
cache without requiring disk access. This ratio is computed using data selected from the dynamic
performance view V$SYSSTAT. The buffer cache hit ratio can be used to verify the physical I/O as
predicted by V$DB_CACHE_ADVICE.
Oracle Processes
Oracle Architecture
About Me
sql> select name, value From v$sysstat Where name in (db block gets, consistent gets, physical
reads);
http://oracle-artifacts.blogspot.com/2012/04/collection-of-most-common-dba-interview.html
5/1/2014
The cache-hit ratio can be calculated as follows: Hit ratio = 1 (physical reads / (db block gets +
consistent gets)) If the cache-hit ratio goes below 90% then: increase the initialisation parameter
DB_CACHE_SIZE.
Library cache hit ratio: It calculates how often the parsed representation of the statement can be
reused. It also known as soft parse.
sql> select namespace, pins, pinhits, reloads, invalidations from v$librarycache order by
namespace;
Page 2 of 7
Mudassar
Majgaonkar
Follow
148
12. What spfile/init.ora file parameter exists to force the CBO to make the execution path of a given
statement use an index, even if the index scan may appear to be calculated as more costly?
Ans: OPTIMIZER_INDEX_COST_ADJ= FORCE
13. Assuming today is Monday, how would you use the DBMS_JOB package to schedule the
execution of a given procedure owned by SCOTT to start Wednesday at 9AM and to run
subsequently every other day at 2AM.
Ans: dbms_job.submit(:jobno,'statspack.snap;',trunc(sysdate)+9/24,'trunc(SYSDATE+1/24,''HH'')',
TRUE, :instno);
14. How would you edit your CRONTAB to schedule the running of /test/test.sh to run every other
day at 2PM?
Ans: 00 02 * * * /test/test.sh
15. In which dictionary table or view would you look to determine at which time a snapshot or
MVIEW last successfully refreshed?
Ans: SQL> SELECT MVIEW_NAME,LAST_REFRESH_DATE from USER_MVIEWS;
16. How would you best determine why your MVIEW couldnt FAST REFRESH?
Ans: Possibly by checking the MVIEW LOG for errors.
http://oracle-artifacts.blogspot.com/2012/04/collection-of-most-common-dba-interview.html
5/1/2014
Page 3 of 7
Run the following query to find out the p1,p2 and p3 of a session causing buffer busy wait
sql> select p1 "File #",p2 "Block #",p3 "Reason Code" from v$session_wait where event = 'buffer
busy waits';
After that running the following query to find the segment causing buffer busy wait:-
sql> select owner,segment_name,segment_type from dba_extents where file_id = &P1 and &P2
between block_id and block_id + blocks -1;
25. What query tells you how much space a tablespace named test is taking up, and how much
space is remaining?
Ans:
SET SERVEROUTPUT ON
SET LINESIZE 1000
SET FEEDBACK OFF
rem column dummy noprintcolumn pct_used format 999.9
heading "%|Used"
column name format a25
heading "Tablespace Name"
column Kbytes format 999,999,999 heading "MBytes"
column used format 999,999,999 heading "Used(MB)"
column free format 999,999,999 heading "Free(MB)"
column largest format 999,999,999 heading "Largest"
break on report
compute sum of kbytes on report
compute sum of free on report
compute sum of used on report
set pagesize 100
select nvl(b.tablespace_name,
nvl(a.tablespace_name,'UNKOWN')) name,(kbytes_alloc/1024) kbytes,
((kbytes_alloc-nvl(kbytes_free,0))/1024) used,(nvl(kbytes_free,0)/1024) free,
((kbytes_alloc-nvl(kbytes_free,0))/kbytes_alloc)*100 "%used",
nvl(largest,0)/1024 largest
from ( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024 Kbytes_alloc,
tablespace_name
from sys.dba_data_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
order by 1
/
26. Database is hung. Old and new user connections alike hang on impact. What do you do? Your
SYS SQLPLUS session is able to connect.
Ans: Log into the system and find whether there are any deadlocks in the system using the
following query.
select 'SID ' || l1.sid ||' is blocking ' || l2.sid blocking
from v$lock l1, v$lock l2
http://oracle-artifacts.blogspot.com/2012/04/collection-of-most-common-dba-interview.html
5/1/2014
Page 4 of 7
27. Database crashes. Corruption is found scattered among the file system neither of your doing nor
of Oracles. What database recovery options are available? Database is in archive log mode.
Ans: First of all secure all the archives and all the backups you have on the tape or other system.
Then run fschk to check the filesystem. If the corruption is detected at the filesystem level and is not
recoverable by fschk format the file system and restore the database through RMAN.
28. Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/or
Solaris).
Ans:
29. How do you increase the OS limitation for open files (LINUX and/or Solaris)?
Ans: Set the file-max parameter is /etc/sysctl.conf to the number you want.Save the file and
execute it by using command /etc/sysctl.conf-p
30. Provide an example of a shell script which logs into SQLPLUS as SYS, determines the current
date, changes the date format to include minutes & seconds, issues a drop table command,
displays the date again, and finally exits.
Ans:
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/ora10g
export ORACLE_SID=ora10g
export path=$ORACLE_HOME/lib
sqlplus sys as sysdba << EOF
@/oracle/date.sql
exit;
Now the contents of /oracle/date.sql
select SYSDATE from dual;
select to_char(SYSDATE,'dd-mon-yyyy hh24:mi:ss') from dual;
drop table tablename cascade constraints;
select to_char(SYSDATE,'dd-mon-yyyy hh24:mi:ss') from dual;
/
31. Explain how you would restore a database using RMAN to Point in Time?
Ans:
restore database
until time "to_date('Aug 27 2001 02:00:00','Mon DD YYYY HH24:MI:SS')";
recover database
http://oracle-artifacts.blogspot.com/2012/04/collection-of-most-common-dba-interview.html
5/1/2014
Page 5 of 7
Ans: Oracle enables you to define and enforce data integrity constraints like PRIMARY KEY
CONSTRAINTS, FOREIGN KEY CONSTRAINTS and UNIQUE CONSTRAINTS.
33. Which environment variables are absolutely critical in order to run the OUI?
Ans: ORACLE_BASE, ORACLE_HOME, ORACLE_SID,path and library path
34. What SQL query from v$session can you run to show how many sessions are logged in as a
particular user account?
Ans: select count(1) from v$session where USERNAME='username';
35. Why does Oracle not permit the use of PCTUSED with indexes?
Ans: Imagine you've got an index on people's names. And, just for the sake of argument, only 4 entries can fit
in a block.
So you have
Adam
Bob
Charles
David
and
Edward
Frank
Graham
Howard
You want to insert a new entry in the table (and hence into the index on that table) of Zebedee.
As things stand, both blocks of the index are full, so Zebedee has to go into a third block all on his
own.
Now say you delete some existing rows:
delete from employees where name in ('Bob', 'Charles', 'David'). You're left in this state:
Block 1:
Adam
Block 2:
Edward
Frank
Graham
Howard
That means block 1 has 3 empty slots for new entries. So you still want to insert a record for
someone called Zebedee: can it go into the first block, with all that empty space? No. Because if it
did, you'd end up with an index that ran:
Adam
Zebedee
Edward
Frank
Graham
Howard
...and you might notice that the alphabetical order has been screwed to buggery at this point. So no,
although the first block contains lots of empty space, it's still defined as an "A-ish" sort of block. It
actually has to have entries between Adam and Edward, and it can't suddenly decide to accept
entries from Wilma, Susan or Mary.
So when can block 1 be used to house those sorts of entries? When Adam gets deleted. Because
when that row goes, you're in this position:
Block 1: completely empty
Block 2: values from E to G
Being completely empty, there's no "A or B'ness' about block 1 any more. So suddenly, it can
accept any entry at all. Now, physically, block 1 might come "before" block 2... but we jig things
http://oracle-artifacts.blogspot.com/2012/04/collection-of-most-common-dba-interview.html
5/1/2014
Page 6 of 7
around in the root and branch blocks so that doesn't matter. Therefore, you can now insert all those
other records you wanted and get this situation:
Block 1:
Mary
Susan
Wilma
Zebedee
Block 2:
Edward
Frank
Graham
Howard
And we have a branch block (actually, in this case, the root node) which says:
A -> L: goto block 2
M -> Z: goto block 1
So, once we deleetd Adam, we were allowed to insert new items into all that empty space. But of
course, once we deleted Adam, the first block was completely and utterly empty. And what does a
completely empty block equate to in PCTUSED terms? Er, 0%.
It has to be 0% PCTUSED, in other words, because entries in an index have to be organised
according to some order. Allowing you to reuse space 'out of order' would destroy the point of an
index. And you can only say, "Order is irrelevant at this point" when no entries exist at all... which
equates to PCTUSED of 0.
PCTFREE is fine to set, because that simply says when to stop filling one block and start filling
another. In indexes, it reserves space that might come in handy for preventing block splits. So
there's a use for PCTFREE, definitely. Imagine we'd set PCTFREE of 25%. Then the earlier index
would be:
Block 1:
Adam
Bob
Charles
Block 2:
David
Edward
Frank
Block 3:
Graham
Howard
With a PCTFREE of 25% and only 4 entries allowed per block, we end up only storing 3 entries per
block: the missing entry being reserved as 'free space'. Now insert a guy called 'Brian': is there
room to fit him between Bob and Charles? In this new index, yes: block 1 is allowed to grow to
holding 4 records, and there's only currently 3, so yup: there's room to accomodate the new guy.
But in the earlier example? No, the block was allowed to hold four records. It's holding four records.
You want to insert a new one that HAS to go between two existing records... we have to perform a
block split and reorganisation to allow that to happen. Block splits are costly affairs. PCTFREE
would have saved us from having to do one.
So yes, PCTFREE in an index is useful. PCTUSED is meaningless. Once you impose an order on
rows, they cannot just go anywhere. Space reserved for future inserts is fine. But a flag to say
'insert away!' when inserting would disrupt a carefully-achieved ordering is a complete no-no.
3 comments:
Anonymous May 10, 2013 at 11:46 AM
http://oracle-artifacts.blogspot.com/2012/04/collection-of-most-common-dba-interview.html
5/1/2014
Page 7 of 7
Anybody who's asking question during an interview like 25 and 26 are out of their mind. It could be
just a description of what you would do in this situation, but not specific queries.
BTW there are several small and BIG mistakes that I've spotted right away in your answers.
Specifically, #31 is a big one and #33 is a small one.
Reply
Mudassar Majgaonkar
Hi Anonymous,
Some companies do ask it and trust me that Time I also thought they are out of their mind... But then
nonetheless they are interviewers :)
And thanks for pointing out the mistake and your valuables comments
Reply
Comment as:
Publish
Select profile...
Preview
Newer Post
Home
Older Post
http://oracle-artifacts.blogspot.com/2012/04/collection-of-most-common-dba-interview.html
5/1/2014