Oracle DBA Interview Questions and Answers


1.  Explain the difference between $ORACLE_HOME and $ORACLE_BASE? 

ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where the oracle products reside.

2. When a user process fails, what background process cleans up after it?

   PMON

3. What command would you use to create a backup control file?
Alter database backup control file to trace.

4.  How would you go about increasing the buffer cache hit ratio?

Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. If a change was necessary then I would use the alter system set db_cache_size command.
5.  What background process refreshes materialized views?

The Job Queue Processes.

6. How would you determine what sessions are connected and what resources they are waiting for?

Use of V$SESSION and V$SESSION_WAIT

7. Describe what redo logs are?

Redo logs are logical and physical structures that are designed to hold all the changes made to a database and are intended to aid in the recovery of a database.

8. How would you force a log switch?

ALTER SYSTEM SWITCH LOG FILE;


9. Name a table-space automatically created when you create a database?

The SYSTEM table-space.

10.  What are the minimum parameters should exist in the parameter file (init.ora) ?

DB NAME -  Must set to a text string of no more than 8 characters and it will be stored inside the datafiles, redo log files and control files and control file while database creation.

DB_DOMAIN - It is string that specifies the network domain where the database is created. The global database name is identified by setting these parameters

(DB_NAME & DB_DOMAIN) CONTORL FILES - List of control filenames of the database. If name is not mentioned then default name will be used.

DB_BLOCK_BUFFERS - To determine the no of buffers in the buffer cache in SGA.

PROCESSES - To determine number of operating system processes that can be connected to ORACLE concurrently. The value should be 5 (background process) and additional 1 for each user.

ROLLBACK_SEGMENTS - List of rollback segments an ORACLE instance acquires at database startup. Also optionally LICENSE_MAX_SESSIONS,LICENSE_SESSION_WARNING and LICENSE_MAX_USERS.

15. Explain the difference between a data block, an extent and a segment? 

A data block is the smallest unit of logical storage for a database object. As objects grow they take chunks of additional storage that are composed of contiguous data blocks. These groupings of contiguous data blocks are called extents. All the extents that an object takes when grouped together are considered the segment of the database object.

16. Compare and contrast TRUNCATE and DELETE for a table? 

Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete.

18. What is the difference between restoring and recovering?

Restoring involves copying backup files from secondary storage (backup media) to disk. This can be done to replace damaged files or to copy/move a database to a new location.
Recovery is the process of applying redo logs to the database to roll it forward. One can roll-forward until a specific point-in-time (before the disaster occurred), or roll-forward until the last transaction recorded in the log files. Sql> connect SYS as SYSDBA
Sql> RECOVER DATABASE UNTIL TIME '2001-03-06:16:00:00' USING BACKUP CONTROLFILE;

19. When creating a user, what permissions must you grant to allow them to connect to the database?

Grant the CONNECT to the user.
21. How do you add a data file to a tablespace?

ALTER TABLESPACE <tablespace_name> ADD DATAFILE <datafile_name> SIZE

22. What is SAVE POINT?

For long transactions that contain many SQL statements, intermediate markers or savepoints can be declared which can be used to divide a transaction into smaller parts. This allows the option of later rolling back all work performed from the current point in the transaction to a declared savepoint within the transaction.

23. What is mean by Program Global Area (PGA)?

It is area in memory that is used by a Single Oracle User Process.

24. How does one manage Oracle database users?

Oracle user accounts can be locked, unlocked, forced to choose new passwords, etc. For example, all accounts except SYS and SYSTEM will be locked after creating an Oracle9iDB database using the DB Configuration Assistant (dbca). DBA's must unlock these accounts to make them available to users.
Look at these examples:
ALTER USER scott ACCOUNT LOCK -- lock a user account
ALTER USER scott ACCOUNT UNLOCK; -- unlocks a locked users account
ALTER USER scott PASSWORD EXPIRE; -- Force user to choose a new password

25. How does one tune Oracle Wait events?

Some wait events from V$SESSION_WAIT and V$SYSTEM_EVENT views:
Event Name:
Tuning Recommendation:
db file sequential read
Tune SQL to do less I/O. Make sure all objects are analyzed. Redistribute I/O across disks.
buffer busy waits
Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i)/ Analyze contention from SYS.V$BH
log buffer spaces
Increase LOG_BUFFER parameter or move log files to faster disks

28. What is SQL*Loader and what is it used for?

SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. Its syntax is similar to that of the DB2 Load utility, but comes with more options. SQL*Loader supports various load formats, selective loading, and multi-table loads.
 
29. WHAT IS RMAN?

Recovery Manager is a tool that: manages the process of creating backups and also manages the process of restoring and recovering from them.

30. What is hit ratio?

It is a measure of well the data cache buffer is handling requests for data. Hit Ratio = (Logical Reads - Physical Reads - Hits Misses)/ Logical Reads.

31. What happens when you run ALTER DATABASE OPEN RESETLOGS ? The current online redo 

logs are archived, the log sequence number is reset to 1, new database incarnation is created, 
and the online redo logs are given a new time stamp and SCN.

32. In what scenarios open resetlogs required ?

An ALTER DATABASE OPEN RESETLOGS statement is required after incomplete recovery 
(Point in Time Recovery) or recovery with a backup control file.

33 . What is SCN (System Change Number) ?

The system change number (SCN) is an ever-increasing value that uniquely identifies a 
committed version of the database at a point in time. Every time a user commits a transaction
Oracle records a new SCN in redo logs.
                        Oracle uses SCNs in control files datafile headers and redo records. Every redo log file has both a log sequence number and low and high SCN. The low SCN records the lowest SCN recorded in the log file while the high SCN records the highest SCN in the log file.

36. Give one method for transferring a table from one schema to another? There are several 

possible methods, export-import, CREATE TABLE... AS SELECT, or COPY.

37. What is the purpose of the IMPORT option IGNORE? What is it?s default setting?

The IMPORT IGNORE option tells import to ignore "already exists" errors. If it is not specified the tables that already exist will be skipped. If it is specified, the error is ignored and the tables data will be inserted. The default value is N.

38. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE USER command what happens? Is this bad or good? Why?

The user is assigned the SYSTEM tablespace as a default and temporary tablespace. This is bad because it causes user objects and temporary segments to be placed into the SYSTEM tablespace resulting in fragmentation and improper table placement (only data dictionary objects and the system rollback segment should be in SYSTEM).

39. What are some of the Oracle provided packages that DBAs should be aware of?

Oracle provides a number of packages in the form of the DBMS_ packages owned by the SYS user. The packages used by DBAs may include: DBMS_SHARED_POOL, DBMS_UTILITY, DBMS_SQL, DBMS_DDL, DBMS_SESSION, DBMS_OUTPUT and DBMS_SNAPSHOT. They may also try to answer with the UTL*.SQL or CAT*.SQL series of SQL procedures. These can be viewed as extra credit but aren?t part of the answer.

39. What happens if the constraint name is left out of a constraint clause?

The Oracle system will use the default name of SYS_Cxxxx where xxxx is a system generated number. This is bad since it makes tracking which table the constraint belongs to or what the constraint does harder.

40. What happens if a tablespace clause is left off of a primary key constraint clause?

 This results in the index that is automatically generated being placed in then users default tablespace. Since this will usually be the same tablespace as the table is being created in, this can cause serious performance problems.

41. What is the proper method for disabling and re-enabling a primary key constraint?

You use the ALTER TABLE command for both. However, for the enable clause you must specify the USING INDEX and TABLESPACE clause for primary keys.

42. What happens if a primary key constraint is disabled and then enabled without fully specifying the index clause?


Expected answer: The index is created in the user?s default tablespace and all sizing information is lost. Oracle doesn?t store this information as a part of the constraint definition, but only as part of the index definition, when the constraint was disabled the index was dropped and the information is gone.

43. (On UNIX) When should more than one DB writer process be used? How many should be used?

If the UNIX system being used is capable of asynchronous IO then only one is required, if the system is not capable of asynchronous IO then up to twice the number of disks used by Oracle number of DB writers should be specified by use of the db_writers initialization parameter.

44. You are using hot backup without being in archivelog mode, can you recover in the event of a failure? Why or why not?


Expected answer: You can?t use hot backup without being in archivelog mode. So no, you couldn?t recover.

45. What causes the "snapshot too old" error? How can this be prevented or mitigated?

This is caused by large or long running transactions that have either wrapped onto their own rollback space or have had another transaction write on part of their rollback space. This can be prevented or mitigated by breaking the transaction into a set of smaller transactions or increasing the size of the rollback segments and their extents.

46. How can you tell if a database object is invalid?

By checking the status column of the DBA_, ALL_ or USER_OBJECTS views, depending upon whether you own or only have permission on the view or are using a DBA account.

47. A user is getting an ORA-00942 error yet you know you have granted them permission on the table, what else should you check?

You need to check that the user has specified the full name of the object (select empid from scott.emp; instead of select empid from emp;) or has a synonym that points to the object (create synonym emp for scott.emp;)

48. A developer is trying to create a view and the database won?t let him. He has the "DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT grants on the tables he is using, what is the problem?

You need to verify the developer has direct grants on all tables used in the view. You can?t create a stored object with grants given through views.

49. If you have an example table, what is the best way to get sizing data for the production table implementation?

The best way is to analyze the table and then use the data provided in the DBA_TABLES view to get the average row length and other pertinent data for the calculation. The quick and dirty way is to look at the number of blocks the table is actually using and ratio the number of rows in the table to its number of blocks against the number of expected rows.

50. How can you find out how many users are currently logged into the database? How can you find their operating system id?


Expected answer: There are several ways. One is to look at the v$session or v$process views. Another way is to check the current_logins parameter in the v$sysstat view. Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l? command, but this only works against a single instance installation.

51. A user selects from a sequence and gets back two values, his select is:
SELECT pk_seq.nextval FROM dual;What is the problem?

Somehow two values have been inserted into the dual table. This table is a single row, single column table that should only have one value in it.

52.  What are the Architectural components of RMAN?

1.RMAN executable
2.Server processes
3.Channels
4.Target database
5.Recovery catalog database (optional)
6.Media management layer (optional)
7.Backups, backup sets, and backup pieces

53.  What are Channels?

A channel is an RMAN server process started when there is a need to communicate with an I/O device, such as a disk or a tape. A channel is what reads and writes RMAN backup files. It is through the allocation of channels that you govern I/O characteristics such as:
     Type of I/O device being read or written to, either a disk or an sbt_tape 
      Number of processes simultaneously accessing an I/O device
      Maximum size of files created on I/O devices
      Maximum rate at which database files are read
      Maximum number of files open at a time
      
54.  Why is the catalog optional?

Because RMAN manages backup and recovery operations, it requires a place to store necessary information about the database. RMAN always stores this information in the target database control file. You can also store RMAN metadata in a recovery catalog schema contained in a separate database. The recovery catalog
schema must be stored in a database other than the target database.

55.  What does complete RMAN backup consist of ? 

A backup of all or part of your database. This results from issuing an RMAN backup command. A backup consists of one or more backup sets.

56.  What is a Backup set? 

A logical grouping of backup files -- the backup pieces -- that are created when you issue an RMAN backup command. A backup set is RMAN's name for a collection of files associated with a backup. A backup set is composed of one or more backup pieces.


                                                      Thank You 

No comments:

Post a Comment