Friday, March 26, 2010

Oracle DBA Interview Questions and Answers

1)How many memory layers are in the shared pool?
A)Sharedpool contains 3 memory layers.

1.Library cache:
2.Data dictionary cache
3.UGA
Library cache -contains parsed sql statements cursor information execution plansdata dictionary cache -user account information priveleges information datafile segment and extent information stored into the data dictionary cache.

2)How do you find out from the RMAN catalog if a particular archive log has been backed-up?
A)

3) How can you tell how much space is left on a given file system and how much space each of the

file system's subdirectories take-up?

A) #df -k to check free space in KB
    #df -h to check free space in GB

4)Define the SGA and:

• How you would configure SGA for a mid-sized OLTP environment?
• What is involved in tuning the SGA?
A)System Global Area (SGA), which is shared by all server and background  processes and holds the following:
o Database buffer cache
o Redo log buffer
o Shared pool
o Large pool (if configured)

• Program Global Areas (PGA), which is private to each server and background process; there is one PGA for each process. The PGA holds the following:
o Stack areas
o Data areas

What is involved in tuning the SGA?
Answer :Properly size your database buffers (shared_pool, buffer cache, log buffer, etc) by looking at your buffer hit ratios. Pin large objects into memory to prevent frequent reloads
.
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?
A)The cache miss ratio is the the number of cache misses compared to the total number of cache read attempts. This is calculated as follows:


Select sum(getmisses) / sum(gets) "Miss ratio" From v$rowcache;

The miss ratio should be less than 15%. If this is not the case, increase the initialisation parameter SHARED_POOL_SIZE

6)Other than making use of the statspack utility, what would you check when you are monitoring or

running a health check on an Oracle 8i or 9i database?
A)UTLBSTAT.SQL and UTLESTAT.SQL - Begin and end stats monitoring or

Oracle Enterprise Manager - Tuning Pack
TKProf

7. How do you tell what your machine name is and what is its IP addresses?

Answer
Windows: ipconfig
UNIX: ifconfig -a
HP-UX : ifconfig 1an0
Linux : ifconfig

8. How would you go about verifying the network name that the local_listener  is currently using?
Answer: With the command: Show parameter LISTENER. After executing this command in SQL, the result that you will get for HOSTNAME is the network name of the local host.

9. You have 4 instances running on the same UNIX box. How can you determine  Which shared memory and semaphores are associated with which instance?
Answer :

10. What view(s) do you use to associate a user's SQLPLUS session with his  o/s process?
Answer : v$session

11. What is the recommended interval at which to run stats pack snapshots, and why?
Answer :

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?
Answer: optimizer_index_cost_adj

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.
Answer: 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?

Answer: Use vi to edit Crontab file append a line on the file
00 2 * * * /test/test.sh

15. What do the 9i dbms_standard.sql_txt() and dbms_standard.sql_text() procedures do?
Answer: DBMS_STANDARD package provides language facilities that help your application interact with Oracle.
Function sql_txt (sql_text out ora_name_list_t) return binary_integer;

16. In which dictionary table or view would you look to determine at which  time a snapshot or MVIEW last successfully refreshed?
Answer: select owner, mview_name, last_refresh_type, last_refresh_date from dba_mviews;
or select * from dba_snapshot_refresh_times;

17. How would you best determine why your MVIEW couldn't FAST REFRESH?
Answer: from dba_mview_refresh_times (DBMS_MVIEW.EXPLAIN_MVIEW)

18. How does propagation differ between Advanced Replication and Snapshot  Replication (read-only)?
Answer: Advanced Replication can have multiple master sites i.e. you can update at any master site, while snapshot replication only has 1 update site

19. Which dictionary view(s) would you first look at to understand or get a high-level idea of a given Advanced Replication environment?
Answer: dba_repcatlog ; dba_repsites_new ; dba_repextensions

20. How would you begin to troubleshoot an ORA-3113 error?
Answer: End Of File on Communication Channel
The Ora-3113 error is a general error reported by Oracle client tools, which signifies that they cannot communicate with the Oracle shadow process.
Solution
• Increase permanent swap file and test with increasing larger sizes, especially if you are getting 3113 in conjunction with a very large data transfer between client and server.
• (settings -> control panel -> SYSTEM ->performance -> change)
• Sql*Net vs. Database versions mismatch
• Delete unwanted files (like core, .lst, .trc, .log etc) if your executables partition becomes full, especially $ORACLE_HOME
• Set sqlnet.expire_time = 0 in sqlnet.ora file
• If your database is running in archive log mode make sure LOG_ARCHIVE_START = TRUE is set in your init.ora file
• If you have installed Oracle parallel server option but do not have distributed Lock manager installed or running, the 3113 may be encountered
- select * from v$option;

- if you find the two conditions stated above are true, you should de-install the parallel server option. It is recomended to go through Oracle installer to de-install any product, else folow this approach.

- shutdown any Oracle instances
- %script /tmp/relink.out
- %cd $ORACLE_HOME/rdbms/lib
- %rm -f oracle
- %make -f oracle.mk no_parropt ioracle
- %exit

• Try using the SQL*Net V1 driver for local connections:

- setenv TWO_TASK P:

• Your 'Oracle' executable may be corrupt. Relink it

- shutdown any Oracle instances
- %script /tmp/relink.out
- %cd $ORACLE_HOME/rdbms/lib
- %rm -f oracle
- %make -f oracle.mk ioracle
- %exit

• Some unix platform need LD_LIBRARY_PATH to be set correctly to resolve any dynamically linked libraries problems.

• Check the SQL*Net protocol you are using drivers oracle if you are using TCP/IP it should list TCP/IP if driver command does not exists on your machine, then try

- %script /tmp/symbols.out
- %cd $ORACLE_HOME/bin
- %nm oracle
grep -i SYMBOL # where symbol can be osnptt, osnasy, osnttt, osntlitcp, osntlispx, osndnt
- %exit

21. Which dictionary tables and/or views would you look at to diagnose a  locking issue?
Answers: sys.v_$lock, sys.v_$session sys.obj$ , sys.user$ ,
sys.v_$process

22. An automatic job running via DBMS_JOB has failed. Knowing only that  "it's failed", how do you approach troubleshooting this issue?
Answers:


23. How would you extract DDL of a table without using a GUI tool?

Answers:
select dbms_metadata.get_ddl('TABLE','tab_name') from dual;


What is the recommended interval at which to run stats pack snapshots, and why?

The single most common misuse of STATSPACK is the «more is better» approach. Often STATSPACK reports spans hours or even days. The times between the snapshots (the collection points) should, in general, be measured in minutes, not hours and never days.

The STATSPACK reports we like are from 1 5-minute intervals during a busy or peak time, when the performance is at its worst. That provides a very focused look at what was going wrong at that exact moment in time. The problem with a very large STATSPACK snapshot window, where the time between the two snapshots is measured in hours, is that the events that caused serious performance issues for 20 minutes during peak processing don't look so bad when they're spread out over an 8-hour window. It's also true with STATSPACK that measuring things over too long of a period tends to level them out over time. Nothing will stand out and strike you as being wrong. So, when taking snapshots, schedule them about 15 to 30 minutes (maximum) apart. You might wait 3 or 4 hours between these two observations, but you should always do them in pairs and within minutes of each other. 24. You're getting high "busy buffer waits" - how can you find what's  causing it?


25. What query tells you how much space a tablespace named "test" is taking  up, and how much space is remaining?

Answers:

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.
Answers:

27. Database crashes. Corruption is found scattered among the file system  neither of your doing nor of Oracle's. What database recovery options are available? Database is in archive log mode.
Answers:

28. Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/or Solaris).
Answers:

29. How do you increase the OS limitation for open files (LINUX and/or Solaris)?
Answers:

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.
Answers: Create a file.sh using vi then type the following line
sqlplus -s sys/*******@service_name
select sysdate from dual;
ALTER SESSION SET NLS_DATE_FORMAT='YYYY/MM/DD MI:SS'
drop table xx;
select sysdate from dual;
exit;

31. Explain how you would restore a database using RMAN to Point in Time?
Answer: Rman page no 4 – 26 --- 29

32. How does Oracle guarantee data integrity of data changes?


33. Which environment variables are absolutely critical in order to run the  OUI?
Answer: On UNIX: Oracle_Home , Path , ORA_NLS33 AND LD_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?
Answer: Select count (*) from v$session where username=’User_account_name’

35. Why does Oracle not permit the use of PCTUSED with indexes?

36. What would you use to improve performance on an insert statement that  Places millions of rows into that table?

37. What would you do with an "in-doubt" distributed transaction?

38. What are the commands you'd issue to show the explain plan for "select * from dual"?

39. In what script is "snap$" created? In what script is the "scott/tiger" schema created?
Answer :

40. If you're unsure in which script a sys or system-owned object is  created, but you know it's in a script from a specific directory, what UNIX Command from that directory structure can you run to find your answer?
Answer :

41. How would you configure your networking files to connect to a database by the name of DSS which resides in domain icallinc.com?
Answer : In tnsnames use host=DSS.icallinc.com

42. You create a private database link and upon connection, fails with: ORA-2085: connects to . What is the problem? How would you go about resolving this error?

Answer : This happens after the DB_NAME of the database was changed (as in note# 15390.1 ie re-create controfile with set database option etc ...).After This, the NAME column value is the new DB_NAME in V$DATABASE. The problem comes from the PROPS$ where GLOBAL_DB_NAME is still the old database name. So the WA is to execute the ALTER DATABASE RENAME GLOBAL_NAME (global_name=false is not a WA if global_naming is required).

43. I have my backup RMAN script called "backup_rman.sh". I am on the target database. My catalog username/password is rman/rman. My catalog db is called  rman. How would you run this shell script from the O/S such that it would  run as a background process?

Answer : backup_rman.sh >&1&

44. Explain the concept of the DUAL table.
Answer : Dual is a table which is created by oracle along with the data dictionary.  It consists of exactly one column whose name is dummy and one record.
The value of that record is X.

sql> desc dual
Name Null? Type
DUMMY VARCHAR2(1)
sql> select * from dual;
The owner of dual is SYS but dual can be accessed by every user. As dual contains exactly one row (unless someone fiddled with it),  it is guaranteed to return exactly one row in select statements if a constant expression selected against dual, such as in:
select sysdate from dual
Although it is possible to delete the one record, or insert additional records,
one really should not do that!.

45. What are the ways tablespaces can be managed and how do they differ?
Answer : 2 ways Locally Managed or Managed in the dictionary
Locally-managed tablespaces have the following advantages over dictionary-managed tablespaces:
Local management of extents avoids recursive space management operations, which can occur in dictionary-managed tablespaces if consuming or releasing space in an extent results in another operation that consumes or releases space in a rollback segment or data dictionary table.
Local management of extents automatically tracks adjacent free space, eliminating the need to coalesce free extents.

46. From the database level, how can you tell under which time zone a Database is operating?
Answer : select DBTIMEZONE from dual;

47. What's the benefit of "dbms_stats" over "analyze"?
Answer : Starting with the introduction of the dbms_stats package, Oracle provides a simple way for the Oracle professional to collect statistics for the CBO. The old-fashioned analyze table and dbms_utility methods for generating CBO statistics are obsolete and somewhat dangerous to SQL performance because they don't always capture high-quality information about tables and indexes. The CBO uses object statistics to choose the best execution plan for all SQL statements.

The dbms_stats utility does a far better job in estimating statistics, especially for large partitioned tables, and the better stats result in faster SQL execution plans.

48. Typically, where is the conventional directory structure chosen for  Oracle binaries to reside?

Answer : \oracle\ora91\bin ( windows
$Oracle_Home\

49. You have found corruption in a tablespace that contains static tables that is part of a database that is in NOARCHIVE log mode. How would you
Restore the table space without losing new data in the other table spaces?

Answer:



50. How do you recover a data file that has not been physically been backed  up since its creation and has been deleted. Provide syntax example

Answer: Assume that the file ‘/u01/ORADATA/data/data01.dbf’ of tablespace DATA is damaged and you don't have a backup of the data file.

• SVRMGRL

• SVRMGRL> connect internal

• connected

• SVRMGRL> shutdown abort

• Oracle Instance Aborted

• SVRMGRL> startup mount

• Oracle Instance Started

• SVRMGRL> alter database create datafile ‘/u01/ORADATA/data/data01.dbf’;

• Statement Processed

• SVRMGRL> recover datafile ‘/u01/ORADATA/data/data01.dbf’;

• Statement Processed

• SVRMGRL> select * from v$datafile;

• You will see a list of datafiles with their status. If the status of the concerned file has not been reset to ONLINE, issue the following command.

• SVRMGRL> alter database datafile ‘/u01/ORADATA/data/data01.dbf’ online;

• Statement Processed

• SVRMGRL> select * from dba_tablespaces;

• If the status of the tablespace CASE is not ONLINE, then issue the following command.

• SVRMGRL> alter tablespace CASE online;

• Statement Processed

• SVRMGRL> alter database


No comments:

ORACLE DBA Interview Questions and Answers

ORACLE DBA Interview Questions and Answers was created by Naveen Kumar and Vivaan Kumar working as professional bloggers and also working as Network admins, we created Oracle DBA Interview blog to help people who after a good knowledge alos fails to face the interview.