+ All Categories
Home > Documents > Oracle DBA Interview Questions

Oracle DBA Interview Questions

Date post: 03-Nov-2014
Category:
Upload: ramesh158
View: 124 times
Download: 0 times
Share this document with a friend
Description:
Oracle
Popular Tags:
28
Oracle DBA Interview Questions 1. How many memory layers are in the shared pool? Ans - a) library cache b) Dictionary cache c) SQL Area 2. How do you find out from the RMAN catalog if a particular archive log has been backed-up? Ans - LIST BACKUP OF ARCHIVELOG sequence=453; 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? Ans – df -h 4. Define the SGA and: • How you would configure SGA for a mid-sized OLTP environment? • What is involved in tuning the SGA? Ans - Generaly SGA will be configured as below. Size is determined based on several factors like following:- 1-size of database (small, medium or large) 2-whether the application will be OLTP & DSS 3-total memory on the server 4-whether you have other applicatiions on the same server for example Oracle ERP application server & db may be installed on SAME SERVER which require varying memory sizes 5-number of users expected to use application on the server 6-type of users (super users or light users or both) However, if the DB is dedicated to one server alone, and knowing the size of your DB, I would take defaults on the install manual & those of DBCA and play with SGA parameter values in your tuning cycle. 7. Type of connection of session (dedicated or multithreaded) For tuning the SGA involve Tuning the all the component of the SGA ie. a) Shared pool b) Buffer Cache c) Large Pool d) Java Pool 1
Transcript
Page 1: Oracle DBA Interview Questions

Oracle DBA Interview Questions1. How many memory layers are in the shared pool?Ans - a) library cache b) Dictionary cache c) SQL Area

2. How do you find out from the RMAN catalog if a particular archive log has been backed-up?Ans - LIST BACKUP OF ARCHIVELOG sequence=453;

3. How can you tell how much space is left on a given file system and how much space each of thefile system's subdirectories take-up?Ans – df -h

4. Define the SGA and:• How you would configure SGA for a mid-sized OLTP environment?• What is involved in tuning the SGA?Ans - Generaly SGA will be configured as below.

Size is determined based on several factors like following:- 1-size of database (small, medium or large) 2-whether the application will be OLTP & DSS 3-total memory on the server 4-whether you have other applicatiions on the same server for example Oracle ERP application server & db may be installed on SAME SERVER which require varying memory sizes 5-number of users expected to use application on the server 6-type of users (super users or light users or both) However, if the DB is dedicated to one server alone, and knowing the size of your DB, I would take defaults on the install manual & those of DBCA and play with SGA parameter values in your tuning cycle. 7. Type of connection of session (dedicated or multithreaded)

For tuning the SGA involve Tuning the allthe component of the SGA ie.a) Shared poolb) Buffer Cachec) Large Poold) Java Pool

5. What is the cache hit ratio, what impact does it have on performance of an Oracle database andwhat is involved in tuning it?Ans - a) Library cache HIT ratio by v$librarycache b) Dictionary cache HIT ratio by v$rowcache a) Buffer cache HIT ratio should be more than 90% but at the same time Physical read and write should also be considered. (V$SYSSTAT)

6. Other than making use of the statspack utility, what would you check when you are monitoring orrunning a health check on an Oracle 8i or 9i database?Ans – a) OEM b) TKProf

7. How do you tell what your machine name is and what is its IP address?Ans - Window / Linux a)ipconfig / ifconfigb)ner user / hostname

8. How would you go about verifying the network name that the local_listener is currently using?Ans – LSNRCTL and check the listener.log file

9. You have 4 instances running on the same UNIX box. How can you determine which shared

1

Page 2: Oracle DBA Interview Questions

memory and semaphores are associated with which instance?

Ans - ipcs | grep oracle

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

11. What is the recommended interval at which to run statspack snapshots, and why?Ans – 1 Hour prefered

12. What spfile/init.ora file parameter exists to force the CBO to make the execution path of a givenstatement use an index, even if the index scan may appear to be calculated as more costly?

Ans - optimizer_index_cost_adj

13. Assuming today is Monday, how would you use the DBMS_JOB package to schedule theexecution of a given procedure owned by SCOTT to start Wednesday at 9AM and to runsubsequently every other day at2AM.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 otherday at 2PM?Ans - 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() anddbms_standard.sql_text() procedures do?Ans - 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 orMVIEW last successfully refreshed?

17. How would you best determine why your MVIEW couldn't FAST REFRESH?Ans - from dba_mview_refresh_times

18. How does propagation differ between Advanced Replication and Snapshot Replication (readonly)?

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

20. How would you begin to troubleshoot an ORA-3113 error?Ans – This is End of File Communication ERROR , check the sga Memory at OS , increase it.

21. Which dictionary tables and/or views would you look at to diagnose a locking issue?Ans - 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 youapproach troubleshooting this issue?

2

Page 3: Oracle DBA Interview Questions

Ans – check with dba_jobs and reschedule the job again.

23. How would you extract DDL of a table without using a GUI tool?Ans - SELECT dbms_metadata.get_ddl('TABLE','DEPT','SCOTT') FROM DUAL;

24. You're getting high "busy buffer waits" - how can you find what's causing it?Ans – check with STATSPACK then check for which section cause this data blocks, segment header, free list block , Undo header.

25. What query tells you how much space a tablespace named "test" is taking up, and how muchspace is remaining?Ans – we can check it from dba_free_space.

26. Database is hung. Old and new user connections alike hang on impact. What do you do? YourSYS SQLPLUS session IS able to connect.Ans _ check the Alart.log file for error and check the memory of SGA.

27. Database crashes. Corruption is found scattered among the file system neither of your doing norof Oracle's. What database recovery options are available? Database is in archive log mode.Ans – Complete Database Recovery.

28. Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/orSolaris).Ans – TOP command in Linux / VMSTAT 5 on Solaris

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

Ans - echo 65536 > /proc/sys/fs/file-

30. Provide an example of a shell script which logs into SQLPLUS as SYS, determines the currentdate, changes the date format to include minutes & seconds, issues a drop table command, displaysthe date again, and finally exits.

31. Explain how you would restore a database using RMAN to Point in Time?

32. How does Oracle guarantee data integrity of data changes?Ans – Using Constraints

33. Which environment variables are absolutely critical in order to run the OUI?Ans - 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 aparticular user account?Ans – select count(*) from v$session , v$process

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

Ans - This is similar to the setting for PCTUSED on Oracle indexes. Oracle doesn’t allow you to set PCTUSED on an index because it has the ability to tell the optimal time to relink the data block onto the freelist chain. Here’s what happens if you try to specify PCTUSED for an index:

36. What would you use to improve performance on an insert statement that places millions of rowsinto that table?Ans – Disable all the constraints and drop the indexes.

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 isthe "scott/tiger" schema created?

40. If you're unsure in which script a sys or system-owned object is created, but you know it's in a

3

Page 4: Oracle DBA Interview Questions

script from a specific directory, what UNIX command from that directory structure can you run tofind your answer? Ans – pwd , find

41. How would you configure your networking files to connect to a database by the name of DSSwhich resides in domain icallinc.com?Ans - In tnsnames use host=DSS.icallinc.com 42. You create a private database link <link name> and uponconnection, fails with: ORA-2085: <Link name> connects to <fully qualified remote db name>.What is the problem? How would you go about resolving this error?Ans – check the Tnsnames.ora file for the correct entry

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

44. Explain the concept of the DUAL table.Ans – this is a system Table which has one column.

45. What are the ways tablespaces can be managed and how do they differ?Ans - 2 ways Locally Managed or Managed in the dictionaryLocally-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?Ans - select DBTIMEZONE from dual;

47. What's the benefit of "dbms_stats" over "analyze"?Ans - 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.

48. Typically, where is the conventional directory structure chosen for Oracle binaries to reside?Ans – OracleHome\bin

49. You have found corruption in a tablespace that contains static tables that are part of a databasethat is in NOARCHIVE log mode. How would you restore the tablespace without losing new data inthe other tablespaces?

50. How do you recover a datafile that has not been physically been backed up since its creationand has been deleted. Provide syntax example.

Another Set of Questions:

1. Data pump Advantage & Architecture.

Ans - New utilities in Oracle Database 10g take performance and versatility to new levels. New import and export features introduced in Oracle Database 10g, called Oracle

4

Page 5: Oracle DBA Interview Questions

Data Pump, represent a radical departure from the client/server approach to which database users have grown accustomed over the past several generations of Oracle Database. The server now runs export and import jobs. You can load or unload massive amounts of data quickly using parallelization, and you can adjust the degree of parallelism on the fly. Export and import jobs are now restartable, so a failure doesn't necessarily mean starting over. The API is exposed and easy to use; it's simple to create an import or export job from PL/SQL. And once started, such jobs run in the background, but you can check status and make modifications, from anywhere, using the client utilities.

Describing the Oracle Export and Import utilities as slow is like saying the Titanic sprung a small leak. Stories of Export and Import executions running for hours (and sometime days) are commonplace. Oracle has finally created a new data movement utility, called Data Pump, to increase the performance of data transfers. Oracle states that Data Pump’s performance on data retrieval is 60% faster than Export and 15 to 20 times faster on data input than Import. In addition, Oracle states that Data Pump is able to take advantage of parallel processing to increase performance. Hopefully, this will alleviate the performance issues related to transferring data between Oracle databases.

Architecture

Before Oracle Database 10g, (Oracle7 through Oracle9i) the import and export utilities ran as clients and did the bulk of the work. Data being exported was read by the database instance, passed over the connection to the export client, and then written to disk. All the data was single-threaded through the one export process. Data volumes today are often magnitudes larger than when this architecture was first put in place, making that single export process a bottleneck because performance of an export job is limited by the throughput that the export utility can sustain.

With Oracle Database 10g and the new Data Pump architecture, all the work is now done by the database instance, which can parallelize the work in two ways: by creating multiple Data Pump worker-processes to read/write data being exported/imported, and by creating parallel I/O server processes to more quickly SELECT or INSERT that data. Gone is the single-process bottleneck.

2. What are the new parameters in Oracle10g.Ans – db_recovery_file_dest Db_unique_name Sga_target Skip_unusable_indexes

3. Physical Standby Database Vs Logical Standby Database.Physical Standby Databases

A physical standby database is physically identical to the primary database, with on-disk database structures that are identical to the primary database on a block-for-

5

Page 6: Oracle DBA Interview Questions

block basis. The database schema, including indexes, must be the same.

Data Guard maintains a physical standby database by performing managed recovery operations. When it is not performing recovery operations, a physical standby database can be open for read-only operations.

* Managed recovery

The physical standby database is maintained by applying the archived redo logs on the standby system using the Oracle recovery mechanism. The recovery operation applies changes block-for-block using the physical row ID. The database cannot be opened for read or read/write operations while redo data is being applied.

* Open read-only

The physical standby database can be open for read-only operations so that you can execute queries on the database. While open for read-only operations, the standby database can continue to receive redo logs but application of the data from the logs is deferred until the database resumes managed recovery operations.

Although the physical standby database cannot perform both managed recovery and read-only operations at the same time, you can switch between them. For example, you can run a physical standby database to perform managed recovery operations, then open it so applications can perform read-only operations to run reports, and then change it back to perform managed recovery operations to apply outstanding archived redo logs. You can repeat this cycle, alternating between managed recovery and read-only operations, as necessary.

In either case, the physical standby database is available to perform backup operations. Furthermore, the physical standby database will continue to receive redo logs even if they are not being applied at that moment.Benefits of a Physical Standby Database

A physical standby database provides the following benefits:

* Disaster recovery and high availability

A physical standby database enables a robust and efficient disaster recovery and high availability solution. Easy-to-manage switchover and failover capabilities allow easy role reversals between primary and physical standby databases, minimizing the downtime of the primary database for planned and unplanned outages.

* Data protection

Using a physical standby database, Data Guard can ensure no data loss, even in the face of unforeseen disasters. A physical standby database supports all datatypes, and DDL and DML operations that the primary can support. It also provides safeguard against data corruptions and user errors. Storage level physical corruptions on the primary database do not propagate to the standby database. Similarly, logical corruptions or user errors that cause the primary database to be permanently damaged can be resolved. Finally, the redo data is validated when it is applied to the standby database.

* Reduction in primary database workload

6

Page 7: Oracle DBA Interview Questions

Oracle Recovery Manager (RMAN) can use physical standby databases to off-load backups from the primary database saving valuable CPU and I/O cycles. The physical standby database can also be opened in read-only mode to perform reporting and queries.

* Performance

The redo apply technology used by the physical standby database applies changes using low-level recovery mechanisms, which bypass all SQL level code layers and therefore is the most efficient mechanism for applying changes. This makes the redo apply technology a highly efficient mechanism to propagate changes among databases.

Logical Standby Databases

A logical standby database is initially created as an identical copy of the primary database, but it later can be altered to have a different structure. The logical standby database is updated by applying SQL statements. The logical standby database uses LogMiner technology to convert the log information received from the primary database into SQL statements.This allows users to access the standby database for queries and reporting purposes at any time. Thus, the logical standby database can be used concurrently for data protection and reporting operations.

Data Guard automatically applies archived redo log information to the logical standby database by transforming data in the redo logs into SQL statements and then executing the SQL statements on the logical standby database. Because the logical standby database is updated using SQL statements, it must remain open. Although the logical standby database is open for read/write operations, its target tables for the regenerated SQL are available only for read-only operations. While those tables are being updated, they can be used simultaneously for other tasks such as reporting, summations, and queries. Moreover, these tasks can be optimized by creating additional indexes and materialized views on the maintained tables.

A logical standby database has some restrictions on datatypes, types of tables, and types of data definition language (DDL) and data manipulation language (DML) operations. Unsupported datatypes and tables are described in more detail in Section 4.1.4.Benefits of a Logical Standby Database

A logical standby database provides similar disaster recovery, high availability, and data protection benefits as a physical standby database. It also provides the following specialized benefits:

* Efficient use of standby hardware resources

A logical standby database can be used for other business purposes in addition to disaster recovery requirements. It can host additional databases schemas beyond the ones that are protected in a Data Guard configuration, and users can perform normal DDL or DML operations on those schemas any time. Because the logical standby tables that are protected by Data Guard can be stored in a different physical layout than on the primary database, additional indexes and materialized views can be created to improve query performance and suit specific business requirements.

7

Page 8: Oracle DBA Interview Questions

* Reduction in primary database workload

A logical standby database can remain open at the same time its tables are updated from the primary database, and those tables are simultaneously available for read access. This makes a logical standby database an excellent choice to do queries, summations, and reporting activities, thereby off-loading the primary database from those tasks and saving valuable CPU and I/O cycles.

you cannot have DataGuard with Oracle SE. Either you upgrade to EE or with or without DataGuard (Enterprise Edition), you can implement manual (user-managed) recovery for a physical standby. This means write your own scripts to copy archived redo logs to the standby site and then recover the standby database using them. This would only simulate "maximum performance" mode.

"maximum availability mode" and "open read only for reporting" are conflicting goals. If you want to roll forward your physical standby manually say, once every 24 hours, and then open it for read-only reporting each day, that is very reasonable and achievable with Standard Edition (assuming you can write good scripts).

4. Lost 1 table 2 days back how to recover that table explain.Ans - There could be 4 Option

1. import the table from the dump file.2. Recover from the Flash Recovery3. Recover database Until time4. Recover TSPITR

Case 1 : The current time is 12 p.m. on 9-Dec-97. Your training DBA just told you he dropped theemployee (EMP) table. The table was dropped around 11:45 a.m. Database activity is minimal becausemost staff are currently in a meeting. The table must be recovered.Steps Explanation and Commands1 If the database is open, shut it down using either the “normal” or “immediate” options.SVRMGR> Shutdown immediate2 Restore all datafiles from backup (the most recent if possible):$ cp /disk1/backup/*.dbf /disk1/data/3 Mount the database.SVRMGR> Startup mount4 Recover the database:SVRMGR> recover database until time ‘1997-12-09:11:44:00’;5 To synchronize datafiles with control files and redo logs, open data-base using “resetlogs” option:SVRMGR> alter database open resetlogs;6 Perform a full database backup.7 When recovery is successful and the backup has completed, notify users that the database isavailable for use, and any data entered after the recovery time (11:44 a.m.) will need to bereentered.

5. How to check / synchronize Primary Database with Standby database. (views)

Ans - You can verify archive logs and SCN’s on primary and standby databases by comparing results for the two following queries.

COL name FORMAT a48;SELECT name, first_change#, next_change# FROM v$archived_log;

SELECT name, checkpoint_change#, archive_change# FROM v$database;

8

Page 9: Oracle DBA Interview Questions

SELECT * FROM v$logstdby; SELECT facility,severity,error_code "Err",callout "Cal",timestamp,message FROM v$dataguard_statusORDER BY timestamp;SELECT severity,message FROM v$dataguard_statusORDER BY timestamp; Use this query to verify Log Apply services are functioning properly.

SELECT APPLIED_SCN, APPLIED_TIME, READ_SCN, READ_TIME,NEWEST_SCN, NEWEST_TIMEFROM DBA_LOGSTDBY_PROGRESS; When APPLIED_SCN and NEWEST_SCN values are equal all availablechanges are applied. If APPLIED_SCN is less than NEWEST_SCN then SQLApply is currently not working. Obviously we can check archives on both databases. On the primary run this query:

SELECT name FROM v$archived_log;

On the standby run this query:

SELECT FILE_NAME, SEQUENCE#, FIRST_CHANGE#, NEXT_CHANGE#,TIMESTAMP, DICT_BEGIN, DICT_END, THREAD#FROM DBA_LOGSTDBY_LOG ORDER BY SEQUENCE#;

This query can also be used to verify archives on the standby database and Primary database you can run this query on both the servers.

SELECT serial#,logstdby_id,type,status FROM v$logstdby;

6. What are the Modes of Materialize views?Ans- In Oracle9i, if you specify REFRESH FAST for a single-table aggregate materialized view, you must have created a materialized view log for the underlying table, or the refresh command will fail. When creating a materialized view, you have the option of specifying whether the refresh occurs manually (ON DEMAND) or automatically (ON COMMIT, DBMS_JOB). To use the fast warehouse refresh facility, you must specify the ON DEMAND mode. To refresh the materialized view, call one of the procedures in DBMS_MVIEW.

7. Which permanent data file which store uncommitted data?

Ans - Uncommitted Data on the Data Files

9

Page 10: Oracle DBA Interview Questions

If the user's server process is unable to find a free data buffer, DBWR is notified to flush a section of changed data buffers to their corresponding data files. The section of data buffers being flushed may contain both committed and uncommitted changes.

This could result in Oracle having uncommitted and committed data blocks on the data files. Oracle, for performance reasons, will not check each block in the section being flushed to see if it contains uncommitted data. Oracle wants to write that section as quickly as possible.

A key point is that before this "panic flush" of changed data buffers to disk occurs, DBWR will signal LGWR to write all before images of uncommitted blocks in the section being flushed. This process ensures that all before images of uncommitted data changes can be retrieved from the redo log file during a recovery.

Committed Data Not On the Data Files

When a transaction commits, the server process places a commit record in the log buffer and tells LGWR to perform a contiguous write of all the redo log buffer entries up to and including the commit record to the redo log files (not the data files!).

Oracle is now able to guarantee that the changes will not be lost even if there is an instance failure. Please note that the flushing of dirty data buffers is performed independently by DBWR and can occur either before or after the commit. This could result in Oracle having committed data on the redo log files but not on the data files.

The Synchronization Process

If a failure occurs and the instance terminates abnormally, Oracle must restore the database to a transaction consistent state just prior to the failure. The database must remove all uncommitted data from the data files (because of "panic flushes") and replay all changes committed and recorded in the redo log files but not recorded on the data files (remember that a commit forces LGWR to flush, not DBWR). Oracle restores the database to a transaction consistent state using roll forward and roll backward processes.

8. How to convert Dictionary Managed Table space to Locally Managed Table space.

Ans - Convert between LMT and DMT:

The DBMS_SPACE_ADMIN package allows DBAs to quickly and easilyconvert between LMT and DMT mode. Look at these examples: Example : SQL> exec dbms_space_admin.Tablespace_Migrate_TO_Local('ts1'); SQL> exec dbms_space_admin.Tablespace_Migrate_FROM_Local('ts2');

10

Page 11: Oracle DBA Interview Questions

9. Control file lost how to recover. You don’t have any backup.

Ans _ Create Control file manually and recover database.

10. What is Data Guard what are the advantages.

Ans - Data Guard Broker

Oracle's Data Guard Broker is the management framework that is used to create, configure, administer and monitor a Data Guard environment. The Data Guard Broker provides the following benefits:

Simplifies the creation of Data Guard environments by providing wizards to create and configure physical or logical standby databases. Data Guard is able to generate all of the files necessary (parameter, tnsnames.ora, etc.) to establish the connectivity between the standby and primary database servers.

Allows administrators to invoke a failover or switchover operation with a single command and control complex role changes across all systems in the configuration. A switchover is a planned transfer of control from the primary to the standby while a failover is an unplanned transfer of control due to some unforeseen event. By automating activities such as failover and switchover, the possibility of errors is reduced.

Provides performance-monitoring tools to monitor log transport and log apply times.

Provides a GUI interface (Data Guard Manager) tool that allows DBAs to administer a primary /multiple standby configuration with a simple point-and-click interface.

Administrators are able to manage all components of the configuration, including primary and standby servers and databases, log transport services, and log apply services.

Is highly integrated with Oracle Enterprise Manager to provide e-mail and paging capabilities

An Oracle background server process called DMON is started on every site that is managed by the broker. The DMON process is created when the Data Guard Broker monitor is started on the primary or standby database servers. The DMON process is responsible for interacting with the local instance and the DMON processes running on the other servers to perform the functions requested by the Data Guard Manager or command line interface. The DMON process is also responsible for monitoring the health of the broker configuration.

DMON maintains a persistent configuration file on all of the servers managed by the Data Guard Broker framework. The configuration file contains entries that provide details on all objects in the configuration and their statuses. The broker uses this information to

11

Page 12: Oracle DBA Interview Questions

send information back to the Data Guard Manager, configure and start the site and database resource objects and control each object's behavior.

11. What is Oracle ASM what are its advantages?Ans- the advantages of ASM?

Disk Addition—Adding a disk becomes very easy. No downtime is required and file extents are redistributed automatically.

I/O Distribution—I/O is spread over all the available disks automatically, without manual intervention, reducing chances of a hot spot.

Stripe Width—Striping can be fine grained as in Redo Log Files (128K for faster transfer rate) and coarse for datafiles (1MB for transfer of a large number of blocks at one time).

Buffering—The ASM filesystem is not buffered, making it direct I/O capable by design.

Kernelized Asynch I/O—There is no special setup necessary to enable kernelized asynchronous I/O, without using raw or third-party filesystems such as Veritas Quick I/O.

Mirroring—Software mirroring can be set up easily, if hardware mirroring is not available.

Automatic load balancing Software data redundancy Software RAID 1 with double or triple mirrors Elimination of fragmentation This seems like a bit of a stretch, as fragmentation may also be

eliminated with the use of Locally Managed Tablespaces, a feature introduced in Oracle 8i.

Elimination of file management

12. What is Mean Time Recovery (MTTR)?

Ans _ Fast-Start Time-Based RecoveryRather than wait for specific events such as log switches to trigger checkpoints, Oracle9i can be instructed to use fast-start checkpointing architecture to allow the DBWn processes to periodically write dirty buffers to disk and incrementally advance the checkpoint position. This results in a reduced Mean Time To Recovery (MTTR) and a reduction in I/O spikes associated with log switches.

The FAST_START_MTTR_TARGET initialization parameter is used to specify the number of seconds crash recovery should take. Oracle uses this target time to configure the the FAST_START_IO_TARGET and LOG_CHECKPOINT_INTERVAL parameters to reduce crash recovery time to a level as close to the target time as possible. The FAST_START_IO_TARGET, LOG_CHECKPOINT_INTERVAL and LOG_CHECKPOINT_TIMEOUT parameters should not be set as they may interfere with the process.

12

Page 13: Oracle DBA Interview Questions

The maximum value for FAST_START_MTTR_TARGET is 3600 (1 hour), with values exceeding this being rounded down. There is no minimum value, but values that are too low may not be possible to achieve as this is limited by the low limit of the target number of dirty buffers, which is 1000. Added to this is the time mounting the database will take.

If the value is set too low, then the effective MTTR target will be the best MTTR target the system can achieve. If the value is set to high, the effective MTTR is estimated based on the whole buffer cache being dirty. The ESTIMATED_MTTR column in the V$INSTANCE_RECOVERY view can be used to view the effective MTTR. If the parameter setting, shown by the TARGET_MTTR column, is consistently different to the effective MTTR it should be adjusted since this means it is set at an unrealistic value.

Remember that the extra checkpointing required to reduce the crash recovery time may compromise the system performance. A balance must be reached between general system performance and crash recovery time. Set FAST_START_MTTR_TARGET to zero to disable fast-start checkpointing.

The FAST_START_IO_TARGET initialization parameter is used to specify the maximum number of dirty blocks in the buffer cache. Its use has been deprecated in favour of the FAST_START_MTTR_TARGET. In addition the DB_BLOCK_MAX_DIRTY_TARGET parameter has been removed.

13. If there is High CPU Usage in the server who do you diagnosis and resolve on Linux / Solaris Box?

Ans- check the OS CPU usage find which process consume the CPU if its oracle process then find the SQL Statement and tune it.

14. New features of oracle 9i?

15. New features of oracle 10g?Ans - 1. Data Pump

2. Flashback3. Automatic Workload Repository (AWR)

Automatic Workload Repository (AWR) defaults to a collection interval every 30 minutes and collects data that is the foundation for all of the other self-tuning features. AWR is very much like STATSPACK, especially the level-5 STATSPACK collection mechanism where top SQL is collected every hour, based on your rolling thresholds for high-use SQL. In addition to the SQL, AWR collects detailed run-time statistics on the top SQL (disk reads, executions, consistent gets) and uses this information to adjust the rolling collection threshold. This technique ensures that AWR always collects the most resource-intensive SQL.

4. Automatic Storage Management(ASM)The Automatic Storage Management (ASM) feature allows for the automatic stripe-and-mirror everywhere approach to be used to automatically load balance the disk I/O subsystem and remove the need for the DBA to specify physical file locations when allocating a tablespace.

5. Transportable Tablespace

13

Page 14: Oracle DBA Interview Questions

OS file copy is generally much faster than other traditional means of data movement such as export/import or SQL*Loader. However, in Oracle9i Database and below, a restriction limits its usefulness to only a few cases in which both the target and source database run on the same OS platform—you can't transport tablespaces between Solaris and HP-UX, for example.

In Oracle Database 10g, this restriction has disappeared: you can now transport tablespaces between platforms as long as the OS byte orders are identical

6. Audit TrailFirst, FGA now supports DML statements in addition to selects. These changes are recorded in the same place, the table FGA_LOG$, and displayed through the view DBA_FGA_AUDIT_TRAIL. In addition to DMLs, you can now choose to trigger a trail only if all relevant columns are accessed, or even when a few of them are accessed

7. RMANRman enhanced Incremental Backup & Compress Backup set.

16. What is the advantage and disadvantages in Auto extend on and off?Ans - Another disadvantage that hasn't been mentioned yet is the performance impact - if a user is inserting rows and fills up the tablespace to the point it has to extend, then the end user has to incur the cost of waiting for the file to extend. This is avoided if the DBA anticipates the growth and manually pre-extends the datafile, or adds another data file to the tablespace.

17. What are the kernel parameters which are required to change in the time of oracle installation?

shmmax = 2147483648 (To verify, execute: cat /proc/sys/kernel/shmmax)shmmni = 4096 (To verify, execute: cat /proc/sys/kernel/shmmni)shmall = 2097152 (To verify, execute: cat /proc/sys/kernel/shmall) (for 10g R1)shmmin = 1 (To verify, execute: ipcs -lm |grep "min seg size")shmseg = 10 (It's hardcoded in the kernel - the default is much higher)semmsl = 250 (To verify, execute: cat /proc/sys/kernel/sem | awk '{print $1}')semmns = 32000 (To verify, execute: cat /proc/sys/kernel/sem | awk '{print $2}')semopm = 100 (To verify, execute: cat /proc/sys/kernel/sem | awk '{print $3}')semmni = 128 (To verify, execute: cat /proc/sys/kernel/sem | awk '{print $4}')

SHMMAX

The SHMMAX parameter is used to define the maximum size (in bytes) for a shared memory segment and should be set large enough for the largest SGA size. If the SHMMAX is set incorrectly (too low), it is possible that the Oracle SGA (which is held in shared

14

Page 15: Oracle DBA Interview Questions

segments) may be limited in size. An inadequate SHMMAX setting would result in the following:

ORA-27123: unable to attach to shared memory segment

You can determine the value of SHMMAX by performing the following:

# cat /proc/sys/kernel/shmmax33554432

SHMMNI

We now look at the SHMMNI parameters. This kernel parameter is used to set the maximum number of shared memory segments system wide. The default value for this parameter is 4096. This value is sufficient and typically does not need to be changed.

You can determine the value of SHMMNI by performing the following:

# cat /proc/sys/kernel/shmmni4096

Semaphores

Now that we have configured our shared memory settings, it is time to take care of configuring our semaphores. A semaphore can be thought of as a counter that is used to control access to a shared resource. Semaphores provide low level synchronization between processes (or threads within a process) so that only one process (or thread) has access to the shared segment, thereby ensureing the integrity of that shared resource. When an application requests semaphores, it does so using "sets".

18. What are the packages install when you install stats pack.

19. What are the packages install when you install RMAN.Ans – DBMS_RCVMAN , DBMS_BACKUP_RESTORE, DBMS_RCVCAT

20. What are the things we need to check in stats pack report.Ans – 1. Instance Efficiency Percentage

a) Buffer Nowait % b) Buffer Hit%

c) Library Hit%d) Execute to Parse %

2. Load Profilea) Redo sizeb) Logical readsc) Physical reads

15

Page 16: Oracle DBA Interview Questions

d) Physical writese) Parsef) Sorts

3. Top 5 Timed Eventa) CPU Timeb) Direct path read Tempc) Control file parallel writed) Control file sequential read

4. Table space I/O Stats 5. Other Waits:

a) Buffer Busy waitsb) DB file Sequential Readc) DB file scattered readd) Direct Path Reade) Enqueuef) Free Buffer Waitg) Latch Freeh) Library Cache pini) Log file space switch / log buffer eventj) Log file synck) Undo segment statisticsl) Dictionary cache hits and missesm) Table space IO / File I/O

21. What are the things we need to check in Explain plan report

Ans - Remove unnecessary large-table full table scans - Unnecessary full table scans cause a huge amount of unnecessary I/O, and can drag down an entire database. The tuning expert first evaluates the SQL based on the number of rows returned by the query. If the query returns less and 40 percent of the table rows in an ordered table, or 7 percent of the rows in an unordered table), the query can be tuned to use an index in lieu of the full table scan. The most common tuning for unnecessary full table scans is adding indexes. Standard B-tree indexes can be added to tables, and bitmapped and function-based indexes can also eliminate full table scans. The decision about removing a full table scan should be based on a careful examination of the I/O costs of the index scan vs. the costs of the full table scan, factoring in the multiblock reads and possible parallel execution. In some cases an unnecessary full table scan can be forced to use an index by adding an index hint to the SQL statement.

Cache small-table full table scans - In cases where a full table scan is the fastest access method, the tuning professional should ensure that a dedicated data buffer is available for the rows. In Oracle7 you can issue alter table xxx cache. In Oracle8 and

16

Page 17: Oracle DBA Interview Questions

beyond, the small table can be cached by forcing to into the KEEP pool.

Verify optimal index usage - This is especially important for improving the speed of queries. Oracle sometimes has a choice of indexes, and the tuning professional must examine each index and ensure that Oracle is using the proper index. This also includes the use of bitmapped and function-based indexes.

Verify optimal JOIN techniques - Some queries will perform faster with NESTED LOOP joins, others with HASH joins, while other favor sort-merge joins.

22. What is the Advantage of RMAN?Ans – 1. Configure one time 2. Automatic Backup Control file 3. Backup Space Management: Setting Default Retention Policies 4. Improved Archived Log Backup 5. Centrally Maintained Backup Information Catalog 6. Scripting Available 7. Performance Benefit (Multiple Channel allocation parrallel option) 8. No generation of extra redo during open DB backups. 10. Block corruption Detection. 11. Compress Backup ( save disk space)

23. What is PGA_AGGREGATE_TARGET, SHARED_POOL_ADVIVE, PGA_TARGET_ADVICE, DB_CACHE_ADVICE, MTTR

1. Data Cache advice - The v$db_cache_advice utility show the marginal changes in physical data block reads for different sizes of db_cache_size. Bear in mind that the data from STATSPACK can provide similar data as v$db_cache_advice, and most Oracle tuning professionals use STATSPACK and v$db_cache_advice to monitor the effectiveness of their data buffers.

These advisory utilities are extremely important for the Oracle DBA who must adjust the sizes of the RAM areas to meet current processing demands

Using v$db_cache_advice

The following query can be used to perform the cache advice function, once the db_cache_advice has been enabled and the database has run long enough to give representative results.

-- ***********************************************************-- Display cache advice-- ***********************************************************  column c1   heading 'Cache Size (meg)'      format 999,999,999,999 column c2   heading 'Buffers'               format 999,999,999

17

Page 18: Oracle DBA Interview Questions

column c3   heading 'Estd Phys|Read Factor' format 999.90 column c4   heading 'Estd Phys| Reads'      format 999,999,999

select   size_for_estimate          c1,    buffers_for_estimate       c2,   estd_physical_read_factor  c3,    estd_physical_reads        c4from   v$db_cache_advice where   name = 'DEFAULT'and   block_size  = (SELECT value FROM V$PARAMETER                    WHERE name = 'db_block_size')and   advice_status = 'ON';

The output from the script is shown below.  Note that the values range from 10 percent of the current size to double the current size of the db_cache_size.

                                Estd Phys    Estd Phys Cache Size (meg)     Buffers Read Factor        Reads---------------- ------------ ----------- ------------              30        3,802       18.70  192,317,943 <== 10% size              60        7,604       12.83  131,949,536              91       11,406        7.38   75,865,861             121       15,208        4.97   51,111,658             152       19,010        3.64   37,460,786             182       22,812        2.50   25,668,196             212       26,614        1.74   17,850,847             243       30,416        1.33   13,720,149             273       34,218        1.13   11,583,180             304       38,020        1.00   10,282,475 Current Size             334       41,822         .93    9,515,878             364       45,624         .87    8,909,026             395       49,426         .83    8,495,039             424       53,228         .79    8,116,496             456       57,030         .76    7,824,764             486       60,832         .74    7,563,180             517       64,634         .71    7,311,729             547       68,436         .69    7,104,280             577       72,238         .67    6,895,122             608       76,040         .66    6,739,731 <== 2x size

From the above listing we see that increasing the db_cache_size from 304 meg to 334 meg would result in approximately 700,000 less physical reads.  This can be plotted as a 1/x function and the exact optimal point computed as the second derivative of the function:

2. PGA_AGGREGATE_TARGET

Oracle9i has introduced a new advisory utility dubbed v$pga_target_advice.  This utility will show the marginal changes in optimal, one-pass, and multipass PGA execution for different sizes of pga_aggregate_target, ranging from 10% to 200% of the current value.

18

Page 19: Oracle DBA Interview Questions

SELECT ROUND(pga_target_for_estimate/1024/1024) target_mb, estd_pga_cache_hit_percentage cache_hit_perc, estd_overalloc_count

FROM v$pga_target_advice;

24. What is the difference between alter system Vs alter database?Ans - alter database - chages the information n the databse level alter system - changes the information n the instance level, Database - Collection of files storing database information (configuration/datafiles/redo logs etc) Instance - Processes and memory used to manage a database.

Alter databse; performs operations that affect the database Alter system; performs operations that affect the instance

25. How to take incremental logical backup? Ans – EXP INCTYPE= The type of Import being performed: COMPLETE, CUMULATIVE, and INCREMENTAL.

26. What is Bulk Bind or Collect:Ans – new feature in PL/SQL for faster processing of DML. ( Array Processing in Memory)

27. Transportable Tablespace?Ans - OS file copy is generally much faster than other traditional means of data movement such as export/import or SQL*Loader. However, in Oracle9i Database and below, a restriction limits its usefulness to only a few cases in which both the target and source database run on the same OS platform—you can't transport tablespaces between Solaris and HP-UX, for example.

In Oracle Database 10g, this restriction has disappeared: you can now transport tablespaces between platforms as long as the OS byte orders are identical

28. When did a table spanned across table spaces?

Ans – A partitioned table can span across multiple tablespaces.

29. What is Database replication / Advance Replication?Ans - Replication is the process of creating and maintaining replica versions of database objects (e.g. tables) in a distributed database system. Replication can improve performance and increase availability of applications because alternate data access options becomes available. For example, users can access a local database rather than a remote server to minimize network traffic. Furthermore, the application can continue to function if parts of the distributed database are down as replicas of the data might still accessible.

30. What is Database Auditing?

19

Page 20: Oracle DBA Interview Questions

Ans - Traditional Oracle Database auditing options let you track the actions users perform on objects at the macro level on DML / DDL statements.

Implement Dba_audit_trails .

dbms_fga.add_policy

31. What is Database Label security?

32. What is Log miner?

33. What is tkprof and how is it used

Ans- The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.

34. When should you increase copy latches? What parameters control copy latches

When you get excessive contention for the copy latches as shown by the "redo copy" latch hit ratio. You can increase copy latches via the initialization parameter LOG_SIMULTANEOUS_COPIES to twice the number of CPUs on your system.

35. When looking at the estat events report you see that you are getting busy buffer waits. Is this bad? How can you find what is causing it

Buffer busy waits could indicate contention in redo, rollback or data blocks. You need to check the v$waitstat view to see what areas are causing the problem. The value of the "count" column tells where the problem is, the "class" column tells you with what. UNDO is rollback segments, DATA is data base buffers.

20


Recommended