Oracle DBA Interview Questions Answered: Technical

advertisement
PL/SQL Demystified
The best way of learning something is by asking questions. That's why I've organized this
hub in a question-answer format.
The questions range from Basic to Advanced. I gave a concise answer too, only for quick
reference and revision. For detailed answer to each question, refer to any Oracle PL/SQL
online documentation.
Some of these questions were actually asked in my Job Interviews in the US.
I have added some others which I found interesting. Very useful to know.
What is a cursor ? ( Basic)
- Name or handle to a private SQL area where Oracle parses and fetches query results.
How to control how many cursors are open ?(Intermediate)
- Set OPEN_CURSORS parameter in initialization parameters.
What is shared SQL ? (Intermediate)
-Oracle recognizes similar statements. The SQL area is used many times for similar
statements.
What is Parsing ? (Intermediate)
- Syntax checking, privileges checking, allocating Private SQL Area.
What is the difference between anonymous blocks and stored procedures ? ( Basic)
- Anonymous block is compiled only when called.
- Stored procedure is compiled and stored in database with the dependency information as
well.
- Former is PL/SQL code directly called from an application. Latter is stored in database.
- Former has declare statement.Latter doesnt.
What are the advantages of procedures ? ( Basic)
- Loaded once and used many times
- Performance better coz all SQL stmts are sent in one go from the application to the
database
- Security ( no object privileges are given directly )
- Invoker's rights possible
- Data integrity, productivity
What are standalone procedures ? (Basic)
- Those that are not part of package
How is a PL/SQL program stored in database ? (Advanced)
- Parsed code is stored. It's called P-code
How is a PL/SQL program executed ?(Advanced)
- Prior to Oracle 9i, we have only bytecode and a virtual machine in the database runs it.
Later versions have faster native code execution.
- PL/SQL engine is the main component that executes procedural stmt and passes the SQL
to the SQL statement executor.
What are the advantages and disadvantages of DBMS_SQL ? (Intermediate)
- It has all the advantages of dynamic sql .. like runtime construction of sql, DDL statements
can be executed.
- Its advantage over EXECUTE IMMEDIATE is it can Describe objects
- It's kind of bulky and difficult compared to EXECUTE IMMEDIATE.
What is a package spec and package body ? Why the separation ? ( Basic)
- Spec declares public constructs. Body defines public constructs, additionally declares and
defines Private constructs
- Separation helps make development easier
- Dependency is simplified. You can modify body without invalidating dependent objects.
What are the advantages of Packages ? ( Basic)
- Encapsulation of code logic
- Privileges to objects can be controlled
- Loaded once into memory , used subsequently.
- Dependency simplified
- Public/private procs, functions, variables
How do you handle exceptions for bulk operations ? (Intermediate)
- Use the SAVE EXCEPTIONS clause ( FORALL index IN bound_clause SAVE
EXCEPTIONS LOOP ... END LOOP )
- Use 'Exceptions When Others' to handle the exceptions
- SQL%BULK_EXCEPTIONS(i).ERROR_CODE,
SQL%BULK_EXCEPTIONS(i).ERROR_INDEX
SQL%BULK_EXCEPTIONS.COUNT
Tell some tips to avoid performance problems in PL/SQL. (Intermediate to Advanced)
- Use FORALL instead of FOR, and use BULK COLLECT to avoid looping many times
- Tune SQL statements to avoid CPU overhead
- Use NOCOPY for OUT and IN OUT if the original value need not be retained. Overhead of
keeping a copy of OUT is avoided.
- Reorder conditional tests to put least expensive ones first
- Minimize datatype conversions => Assign data to exact same type variables
- Use PLS_INTEGER for computation intensive code. NUMBER, INTEGER maintain
precision and scale but not optimized for performance as additional checks are made to
maintain precision and scale.
- Do not use subtypes like POSITIVE, NATURAL, INTEGER as they have additional checks
- Use BINARY_FLOAT, BINARY_DOUBLE
- EXECUTE IMMEDIATE is faster than DBMS_SQL
How to know PL/SQL compile parameters ?(Advanced)
- SHOW PARAMETERS PLSQL
- ALL_PLSQL_OBJECT_SETTINGS
What is MERGE ?( Basic)
- Combination of INSERT and UPDATE
Tell some new features in PL/SQL in 10g (Intermediate to Advanced)
- Regular expression functions REGEXP_LIKE , REGEXP_INSTR, REGEXP_REPLACE,
and REGEXP_SUBSTR
- Compile time warnings
- Conditional compilation
- Improvement to native compilation
- BINARY_INTEGER made similar to PLS_INTEGER
- INDICES OF , VALUES OF in FORALL lets you work on non-consecutive indices
- Quoting mechanism . Instead of quoting single quotes twice everytime, give your own
delimiter to go on using single quotes.
Ex: q'!I'm a string, you're a string.!'
- Flashback Query functions. SCN_TO_TIMESTAMP, TIMESTAMP_TO_SCN
- Implicit conversion between CLOB and NCLOB
- Improved Overloading
- New datatypes BINARY_FLOAT, BINARY_DOUBLE
- Global optimization enabled
- PLS_INTEGER range increased to 32bit
- DYNAMIC WRAP using DBMS_DDL
What is a sequence ? (Basic)
- A database object that offers high-speed access to an integer value
- Guaranteed to be unique (within that sequence).
/ SQLPlus
1. How can variables be passed to a SQL routine? Level: Low
Expected answer: By use of the & symbol. For passing in variables the numbers
1-8 can be used (&1, &2,...,&8) to pass the values after the command into the
SQLPLUS session. To be prompted for a specific variable, place the
ampersanded variable in the code itself: "select * from dba_tables where
owner=&owner_name;" . Use of double ampersands tells SQLPLUS to
resubstitute the value for each subsequent use of the variable, a single
ampersand will cause a reprompt for the value unless an ACCEPT statement is
used to get the value from the user.
2. You want to include a carriage return/linefeed in your output from a SQL script,
how can you do this?
Level: Intermediate to high
Expected answer: The best method is to use the CHR() function (CHR(10) is a
return/linefeed) and the concatenation function "||". Another method, although it is
hard to document and isn?t always portable is to use the return/linefeed as a part
of a quoted string.
3. How can you call a PL/SQL procedure from SQL?
Level: Intermediate
Expected answer: By use of the EXECUTE (short form EXEC) command.
4. How do you execute a host operating system command from within SQL?
Level: Low
Expected answer: By use of the exclamation point "!" (in UNIX and some other
OS) or the HOST (HO) command.
5. You want to use SQL to build SQL, what is this called and give an example
Level: Intermediate to high
Expected answer: This is called dynamic SQL. An example would be: set lines
90 pages 0 termout off feedback off verify off spool drop_all.sql select ?drop
user ?||username||? cascade;? from dba_users where username not in
('SYS','SYSTEM'); spool off Essentially you are looking to see that they know to
include a command (in this case DROP USER...CASCADE;) and that you need
to concatenate using the ?||? the values selected from the database.
Alternately, if you are using PL/SQL, you can do ls_sql_string := 'CREATE
TABLE FRED AS SELECT SYSDATE A_DATE FROM DUAL'; EXECUTE
IMMEDIATE ls_sql_string;
6. What SQLPlus command is used to format output from a select?
Level: low
Expected answer: This is best done with the COLUMN command.
7. You want to group the following set of select returns, what can you group on?
Max(sum_of_cost), min(sum_of_cost), count(item_no), item_no Level:
Intermediate Expected answer: The only column that can be grouped on is the
"item_no" column, the rest have aggregate functions associated with them.
8. What special Oracle feature allows you to specify how the cost based system
treats a SQL statement?
Level: Intermediate to high Expected answer: The COST based system allows
the use of HINTs to control the optimizer path selection. If they can give some
example hints such as FIRST ROWS, ALL ROWS, USING INDEX, STAR, even
better.
9. You want to determine the location of identical rows in a table before
attempting to place a unique index on the table, how can this be done?
Level: High
Expected answer: Oracle tables always have one guaranteed unique column, the
rowid column. If you use a min/max function against your rowid and then select
against the proposed primary key you can squeeze out the rowids of the
duplicate rows pretty quick. For example: select rowid from emp e where e.rowid
> (select min(x.rowid) from emp x where x.emp_no = e.emp_no); In the situation
where multiple columns make up the proposed key, they must all be used in the
where clause.
10. What is a Cartesian product?
Level: Low
Expected answer: A Cartesian product is the result of an unrestricted join of two
or more tables. The result set of a three table Cartesian product will have x * y * z
number of rows where x, y, z correspond to the number of rows in each table
involved in the join.
11. You are joining a local and a remote table, the network manager complains
about the traffic involved, how can you reduce the network traffic?
Level: High
Expected answer: Push the processing of the remote data to the remote instance
by using a view to pre-select the information for the join. This will result in only
the data required for the join being sent across.
12. What is the default ordering of an ORDER BY clause in a SELECT
statement?
Level: Low
Expected answer: Ascending
13. What is tkprof and how is it used?
Level: Intermediate to high Expected answer: 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.
14. What is explain plan and how is it used?
Level: Intermediate to high
Expected answer: The EXPLAIN PLAN command is a tool to tune SQL
statements. To use it you must have an explain_table generated in the user you
are running the explain plan for. This is created using the utlxplan.sql script.
Once the explain plan table exists you run the explain plan command giving as
its argument the SQL statement to be explained. The explain_plan table is then
queried to see the execution plan of the statement. Explain plans can also be run
using tkprof.
15. How do you set the number of lines on a page of output? The width?
Level: Low
Expected answer: The SET command in SQLPLUS is used to control the number
of lines generated per page and the width of those lines, for example SET
PAGESIZE 60 LINESIZE 80 will generate reports that are 60 lines long with a
line width of 80 characters. The PAGESIZE and LINESIZE options can be
shortened to PAGES and LINES.
16. How do you prevent output from coming to the screen?
Level: Low
Expected answer: The SET option TERMOUT controls output to the screen.
Setting TERMOUT OFF turns off screen output. This option can be shortened to
TERM.
17. How do you prevent Oracle from giving you informational messages during
and after a SQL statement execution?
Level: Low
Expected answer: The SET options FEEDBACK and VERIFY can be set to OFF.
18. How do you generate file output from SQL?
Level: Low
Expected answer: By use of the SPOOL command
[edit]
Tuning Questions
1. A tablespace has a table with 30 extents in it. Is this bad? Why or why not.
Level: Intermediate
Expected answer: Multiple extents in and of themselves aren?t bad. However if
you also have chained rows this can hurt performance.
2. How do you set up tablespaces during an Oracle installation?
Level: Low
Expected answer: You should always attempt to use the Oracle Flexible
Architecture standard or another partitioning scheme to ensure proper
separation of SYSTEM, ROLLBACK, REDO LOG, DATA, TEMPORARY and
INDEX segments.
3. You see multiple fragments in the SYSTEM tablespace, what should you
check first?
Level: Low
Expected answer: Ensure that users don?t have the SYSTEM tablespace as
their TEMPORARY or DEFAULT tablespace assignment by checking the
DBA_USERS view.
4. What are some indications that you need to increase the
SHARED_POOL_SIZE parameter?
Level: Intermediate
Expected answer: Poor data dictionary or library cache hit ratios, getting error
ORA-04031. Another indication is steadily decreasing performance with all other
tuning parameters the same.
5. What is the general guideline for sizing db_block_size and
db_multi_block_read for an application that does many full table scans?
Level: High
Expected answer: Oracle almost always reads in 64k chunks. The two should
have a product equal to 64 or a multiple of 64.
6. What is the fastest query method for a table?
Level: Intermediate Expected answer: Fetch by rowid
7. Explain the use of TKPROF? What initialization parameter should be turned on
to get full TKPROF output?
Level: High
Expected answer: 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.
8. When looking at v$sysstat you see that sorts (disk) is high. Is this bad or
good? If bad -How do you correct it?
Level: Intermediate
Expected answer: If you get excessive disk sorts this is bad. This indicates you
need to tune the sort area parameters in the initialization files. The major sort are
parameter is the SORT_AREA_SIZe parameter.
9. When should you increase copy latches? What parameters control copy
latches? Level: high Expected answer: 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.
10. Where can you get a list of all initialization parameters for your instance?
How about an indication if they are default settings or have been changed?
Level: Low
Expected answer: You can look in the init.ora file for an indication of manually set
parameters. For all parameters, their value and whether or not the current value
is the default value, look in the v$parameter view.
11. Describe hit ratio as it pertains to the database buffers. What is the difference
between instantaneous and cumulative hit ratio and which should be used for
tuning?
Level: Intermediate
Expected answer: The hit ratio is a measure of how many times the database
was able to read a value from the buffers verses how many times it had to reread a data value from the disks. A value greater than 80-90% is good, less
could indicate problems. If you simply take the ratio of existing parameters this
will be a cumulative value since the database started. If you do a comparison
between pairs of readings based on some arbitrary time span, this is the
instantaneous ratio for that time span. Generally speaking an instantaneous
reading gives more valuable data since it will tell you what your instance is doing
for the time it was generated over.
12. Discuss row chaining, how does it happen? How can you reduce it? How do
you correct it?
Level: high
Expected answer: Row chaining occurs when a VARCHAR2 value is updated
and the length of the new value is longer than the old value and won?t fit in the
remaining block space. This results in the row chaining to another block. It can
be reduced by setting the storage parameters on the table to appropriate values.
It can be corrected by export and import of the effected table.
13. 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?
Level: high
Expected answer: 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.
14. If you see contention for library caches how can you fix it?
Level: Intermediate
Expected answer: Increase the size of the shared pool.
15. If you see statistics that deal with "undo" what are they really talking about?
Level: Intermediate
Expected answer: Rollback segments and associated structures.
16. If a tablespace has a default pctincrease of zero what will this cause (in
relationship to the smon process)?
Level: High
Expected answer: The SMON process won?t automatically coalesce its free
space fragments.
17. If a tablespace shows excessive fragmentation what are some methods to
defragment the tablespace? (7.1,7.2 and 7.3 only)
Level: High
Expected answer: In Oracle 7.0 to 7.2 The use of the 'alter session set events
'immediate trace name coalesce level ts#';? command is the easiest way to
defragment contiguous free space fragmentation. The ts# parameter
corresponds to the ts# value found in the ts$ SYS table. In version 7.3 the ?alter
tablespace coalesce;? is best. If the free space isn?t contiguous then export,
drop and import of the tablespace contents may be the only way to reclaim noncontiguous free space.
18. How can you tell if a tablespace has excessive fragmentation?
Level: Intermediate
If a select against the dba_free_space table shows that the count of a
tablespaces extents is greater than the count of its data files, then it is
fragmented.
19. You see the following on a status report: redo log space requests 23 redo log
space wait time 0 Is this something to worry about? What if redo log space wait
time is high? How can you fix this?
Level: Intermediate
Expected answer: Since the wait time is zero, no. If the wait time was high it
might indicate a need for more or larger redo logs.
20. What can cause a high value for recursive calls? How can this be fixed?
Level: High
Expected answer: A high value for recursive calls is cause by improper cursor
usage, excessive dynamic space management actions, and or excessive
statement re-parses. You need to determine the cause and correct it By either
relinking applications to hold cursors, use proper space management techniques
(proper storage and sizing) or ensure repeat queries are placed in packages for
proper reuse.
21. If you see a pin hit ratio of less than 0.8 in the estat library cache report is this
a problem? If so, how do you fix it?
Level: Intermediate
Expected answer: This indicate that the shared pool may be too small. Increase
the shared pool size.
22. If you see the value for reloads is high in the estat library cache report is this
a matter for concern?
Level: Intermediate
Expected answer: Yes, you should strive for zero reloads if possible. If you see
excessive reloads then increase the size of the shared pool.
23. You look at the dba_rollback_segs view and see that there is a large number
of shrinks and they are of relatively small size, is this a problem? How can it be
fixed if it is a problem?
Level: High
Expected answer: A large number of small shrinks indicates a need to increase
the size of the rollback segment extents. Ideally you should have no shrinks or a
small number of large shrinks. To fix this just increase the size of the extents and
adjust optimal accordingly.
24. You look at the dba_rollback_segs view and see that you have a large
number of wraps is this a problem?
Level: High
Expected answer: A large number of wraps indicates that your extent size for
your rollback segments are probably too small. Increase the size of your extents
to reduce the number of wraps. You can look at the average transaction size in
the same view to get the information on transaction size.
25. In a system with an average of 40 concurrent users you get the following
from a query on rollback extents: ROLLBACK CUR EXTENTS
--------------------------
R01 11 R02 8 R03 12 R04 9 SYSTEM 4 You have room for each to grow by 20
more extents each. Is there a problem? Should you take any action?
Level: Intermediate
Expected answer: No there is not a problem. You have 40 extents showing and
an average of 40 concurrent users. Since there is plenty of room to grow no
action is needed.
26. You see multiple extents in the temporary tablespace. Is this a problem?
Level: Intermediate
Expected answer: As long as they are all the same size this isn?t a problem. In
fact, it can even improve performance since Oracle won?t have to create a new
extent when a user needs one.
What Happens If You Use a Wrong Connect Identifier?
Of course, you will get an error, if you use a wrong connect identifier. Here is an example of how
SQL*Plus react to a wrong connect identifier:
SQL> CONNECT ggl/retneclgg@WRONG;
ERROR:
ORA-12154: TNS:could not resolve the connect identifier
specified
Warning: You are no longer connected to ORACLE.
What you need to do in this case:
* Check the CONNECT command to make sure that the connect identifier is entered correctly.
* Check the tnsnames.ora file to make sure that the connect identifier is defined correctly.
* Check the tnsnames.ora file to make sure that there is no multiple definitions of the same connect
identifier.
* Check your files system to see if you have multiple copies of tnsnames.ora in different Oracle
home directories, because you installed multiple versions of Oracle. If you do have multiple copies,
make sure your SQL*Plus session is picking up the correct copy of tnsnames.ora.

What’s a PL/SQL table? Its purpose and Advantages?
A PL/SQL table is one dimensional, indexed, unbounded sparsed collection of homogeneous
Data.
PLSQL tables are used to move data into and out of the database and between client side
applications and stored sub-programs. They have attributes such as exits, prior, first, last,
delete ,next . These attributes make PLSQL tables easier to use and applications easier to
maintain.
Advantages:
1 PL\SQL tables give you the ability to hold multiple values in a structure in memory so that a
PL\SQL block does not have to go to the database every time it needs to retrieve one of these
values - it can retrieve it directly from the PL\SQL table in memory.
2 Global temporary tables act as performance enhancers when compared to standard tables as
they greatly reduce the disk IO.
3 They also offer the ease-of-use of standard tables, since standard SQL can be used with them;
no special array-processing syntax is required.

What is a Cursor? How many types of Cursor are there?
A) Cursor is an identifier/name to a work area that we can interact with to access its information. A
cursor points to the current row in the result set fetched. There are three types of cursors. They are
1 Implicit cursors – created automatically by PL/SQL for all SQL Dml statements such as
Insert Update, delete and Select
2 Explicit cursors – Created explicitly. They create a storage area where the set of rows
Returned by a query are placed.
3 Dynamic Cursors – Ref Cursors( used for the runtime modification of the select querry).
Declaring the cursor, Opening the cursor, Fetching data , Closing the cursor(Releasing the work
area) are the steps involved when using explicit cursors.

What is the difference between Function and Procedure?
1..Procedure is a sub program written to perform a set of actions and returns multiple valuesUsing
out parameters or return no value at all.
2..Function is a subprogram written to perform certain computations and return a single value.

What are the modes for passing parameters to Oracle?
There are three modes for passing parameters to subprograms
1.IN - An In-parameter lets you pass values to the subprogram being called. In the subprogram it
acts like a constant and cannot be assigned a value.
2. OUT – An out-parameter lets you return values to the caller of the subprogram. It acts like an
initialized variable its value cannot be assigned to another variable or to itself.
3.INOUT – An in-out parameter lets you pass initial values to the subprogram being called and
returns updated values to the caller.

What is the difference between Truncate and Delete Statement?
1.Truncate – Data truncated by using truncate statement is lost permanently and cannot be
retrieved even by rollback. Truncate command does not use rollback segment during its execution,
hence it is fast.
2. Delete – Data deleted by using the delete statement can be retrieved back by Rollback. Delete
statement does not free up the table object allocated space.

What are Exceptions? How many types of Exceptions are there?
Exceptions are conditions that cause the termination of a block. There are two types of exceptions
1.Pre-Defined – Predefined by PL/SQL and are associated with specific error codes.
2.User-Defined – Declared by the users and are rose on deliberate request. (Breaking a condition
etc.)
Exception handlers are used to handle the exceptions that are raised. They prevent exceptions
from propagating out of the block and define actions to be performed when exception is raised.

What is a Pragma Exception_Init? Explain its usage?
Pragma Exception_Init is used to handle undefined exceptions. It issues a directive to the compiler
asking it to associate an exception to the oracle error. There by displaying a specific error message
pertaining to the error occurred. Pragma Exception_Init (exception_name, oracle_error_name).

What is a Raise and Raise Application Error?
1.Raise statement is used to raise a user defined exception.
2. A raise application error is a procedure belonging to dbms_standard package. It allows to display
a user defined error message from a stored subprogram.

What is the difference between Package, Procedure and Functions?
1.A package is a database objects that logically groups related PL/SQL types, objects, and
Subprograms.
2.Procedure is a sub program written to perform a set of actions and can return multiple values.
3.Function is a subprogram written to perform certain computations and return a single value.
Unlike subprograms packages cannot be called, passed parameters or nested.

How do you make a Function and Procedure as a Private?
Functions and Procedures can be made private to a package by not mentioning their declaration in
the package specification and by just mentioning them in the package body.

How do you kick a Concurrent program from PL/SQL?
Using FND_REQUEST.SUBMIT_REQUEST.

What is an Anonymous block?
Anonymous Block is a block of instructions in PL/SQL and SQL which is not saved under a name
as an object in database schema It is also not compiled and saved in server storage, so it needs to
be parsed and executed each time it is run. However, this simple form of program can use
variables, can have flow of control logic, can return query results into variables and can prompt the
user for input using the SQL*Plus '&' feature as any stored procedure.

What are the two basic parameters that we have to pass while registering PL/SQL
procedure?
Error code and Error Buffer.

How to display messages in Log file and Output file?
Using FND_FILE.PUT_LINE

What is a Trigger ? How many types of Triggers are there?
Trigger is a procedure that gets implicitly executed when an insert/update/delete statement is
issued against an associated table. Triggers can only be defined on tables not on views, how ever
triggers on the base table of a view are fired if an insert/update/delete statement is issued against a
view.
There are two types of triggers, Statement level trigger and Row level trigger.
Insert
After / For each row
Trigger is fired / Update /
Before / For Each statement
Delete

Can we use Commit in a Database Trigger, if ‘No’ then why?
No. Committing in a trigger will violate the integrity of the transaction.

What is Commit, Rollback and Save point?
Commit – Makes changes to the current transaction permanent. It Erases the savepoints and
releases the transaction locks.
Savepoint –Savepoints allow to arbitrarily hold work at any point of time with option of later
committing. They are used to divide transactions into smaller portions.
Rollback – This statement is used to undo work.

What is the difference between DDL, DML and DCL structures?
DDL statements are used for defining data. Ex: Create, Alter, Drop,Truncate,Rename.
DML statements are used for manipulating data. Ex: Insert, update, truncate.
DCL statements are used for to control the access of data. Ex; Grant, Revoke.
TCL statements are used for data saving.Ex; Commit,Rollback,Savepoint.

How can u create a table in PL/SQL procedure?
By using execute immediate statement we can create a table in PLSQL.
Begin
Execute immediate ‘create table amit as select * from emp’;
End;
All DDL,DML,DCL commands can be performed by using this command.

How do we Tune the Queries?
Queries can be tuned by Checking the logic (table joins), by creating Indexes on objects in the
where clause, by avoiding full table scans. Finally use the trace utility to generate the trace file, use
the TK-Prof utility to generate a statistical analysis about the query using which appropriate actions
can be taken.

What is Explain Plan? How do u use Explain Plan in TOAD?
It is a utility provided by toad that gives the statistics about the performance of the query. It gives
information such as number of full table scans occurred, cost, and usage of indexes

What is a TK-PROF and its usage?
Tk-Prof is a utility that reads the trace files and generates more readable data that gives the
statistics about the performance of the query on a line to line basis.

What is Optimization? How many types of Optimization are there?
Rule based Optimization and Cost Based Optimization.

What is the default optimization chosen by Oracle?
Cost based Optimization.

What is the difference between the snapshot and synonym?
7 A snapshot refers to read-only copies of a master table or tables located on a remote node. A
snapshot can be queried, but not updated; only the master table can be updated. A snapshot is
periodically refreshed to reflect changes made to the master table. In this sense, a snapshot is
really a view with periodicity.
8 A synonym is an alias for table, view, sequence or program unit. They are of two types private
and public.

What is the difference between data types char and varchar?
Char reserves the number of memory locations mentioned in the variable declarations, even
though not used (it can store a maximum of 255 bytes). Where as Varchar does not reserve any
memory locations when the variable is declared, it stores the values only after they are assigned (it
can store a maximum of 32767 bytes).

Items are imported from the legacy system using the item import interface using the SRS.
How are items imported using the UNIX /PLSQL commands with out using SRS?
1.From the operating system, use CONCSUB to submit a concurrent program. It's an easiest way
to test a concurrent program.
Normally, CONCSUB submits a concurrent request and returns control to the OS prompt/shell
script without waiting for the request to complete. The CONCSUB WAIT parameter can be used to
make CONCSUB wait until the request has completed before returning control to the OS
prompt/shell script
By using the WAIT token, the utility checks the request status every 60 seconds and returns to the
operating system prompt upon completion of the request. concurrent manager does not abort, shut
down, or start up until the concurrent request completes. If your concurrent program is compatible
with itself, we can check it for data integrity and deadlocks by submitting it many times so that it
runs concurrently with itself.
Syntax: CONCSUB [WAIT= [START=] [REPEAT_DAYS=] [REPEAT_END=]
To pass null parameters to CONCSUB, use '""' without spaces for each null parameter.
In words: single quote double quote double quote single quote
Following is an example of CONCSUB syntax with null parameters:
CONCSUB oe/oe OE 'Order Entry Super User' JWALSH CONCURRENT XOE XOEPACK 4 3 '""' 3
2. To Invoke a Concurrent Program using PL/SQL:
i) Just insert a row in FND_CONCURRENT_REQUESTS with the apropriate parameters and
commit.
ii) Invoke the SUBMIT_REQUEST procedure in FND_REQUEST package.
FND_REQUEST.SUBMIT_REQUEST( 'AR', 'RAXMTR', '', '', FALSE, 'Autoinvoice Master Program',
sc_time, FALSE, 1, 1020, 'VRP', '01-JAN-00', chr(0)

How can the duplicate records be deleted from the table?
delete from t1 a where rowid not in (select max(rowid) from t1 b where a.no=b.no)

What is the significance of _all tables?
All tables are multi-org tables which are associated with the company as a whole. Multiple
Organizations is enabled in Oracle
Applications by partitioning some database tables by the Operating Unit. Other tables are shared
across Operating Units (and therefore across set of books). Examples of Applications with
partitioned tables are Oracle Payables, Oracle Purchasing, Oracle Receivables, Oracle Projects,
Oracle Sales & Marketing etc. The name of each corresponding partitioned table is the view name
appended by '_ALL'

What are mutating tables? And what is mutating error?
A mutating table is a table that is currently being modified by an UPDATE, DELETE, or INSERT
statement, or it is a table that might need to be updated by the effects of a declarative DELETE
CASCADE referential integrity constraint.
A mutating error occurs when a trigger which fires when updation/deletion/insertion is done on a
table A performs insertion/updation/deletion on the same table A. This error results in an infinite
loop which is termed as a mutating error.

What is difference between oracle 7 andoracle 8i?
A) Oracle 7 is a simple RDBMS, where as Oracle 8i is ORDBMS i.e., RDBMS with Object Support.
The main add-ons in version 8 are…
Abstract Data types
Varrays
PL/SQL Tables
Nested Tables
Partitioned Tables

What is Data cleaning and testing.
Data Cleaning: Transformation of data in its current state to a pre-defined, standardized format
using packaged software or program modules.
Data Testing: The agreed upon conversion deliverables should be approved by the client
representatives who are responsible for the success of the conversion. In addition, three levels of
conversion testing have been identified and described in the prepare conversion test plans
deliverables.
Eg: for Summary Balances in GL we set Test Criteria as Record Counts, Hash Totals, Balances,
Journal Debit and Credit.

While registering a report and a pl/sql block we pass some parameters, for any pl/sql block
we pass 2 additional parameters. Can u list them?
It requires two IN parameters for a PL/SQL procedure that's registered as a concurrent program in
Apps. They are
1. Errcode IN VARCHAR2
2. Errbuff IN VARCHAR2

what is a trace file?
when ever an internal error is detected by a process in oracle it dumps the information about the
error into a trace file.
Alter session set sql_trace=TRUE

When do you use Ref Cursors?
We base a query on a ref cursor when you want to:
1.More easily administer SQL
2. Avoid the use of lexical parameters in your reports
3. Share data sources with other applications, such as Form Builder
4. Increase control and securityv) Encapsulate logic within a subprogram
0
ORACLE APP TECHNICAL
Technical Interview Questions in Oracle Apps
|
EPrint
mail
|
Written by Anil Passi
Sunday, 17 September 2006
Please find a list of possible technical interview questions in Oracle Apps. All the contents on this website are Copyright
protected.
I will try to keep this upto date with any new questions that I come accross.
New apps questions will be added to the top of this post.
Most of the Oracle apps interview questions listed here are technical in natue. These interview questions span various
Oracle Apps modules plus FND & OA Framework. For Oracle HRMS and Payroll interview questions visit HRMS Interview
Questions
For Oracle iProcurement interview questions, kindly visit iProc Interview Questions .
Question: How will you migrate Oracle General Ledger Currencies and
Sets of Books Definitions fromone environment to another without
reKeying? Will you use FNDLOAD?
Answer: FNDLOAD can not be used in the scenario. You can use migrator
available in "Oracle iSetup" Responsibility
Question: This is a very tough one, almost impossible to answer, but yet I
will ask. Which Form in Oracle Applications has most number of Form
Functions?
Answer: "Run Reports". And why not, the Form Function for this screen
has a parameter to which we pass name of the "Request Group", hence
securing the list of Concurrent Programs that are visible in "Run Request"
Form. Just so that you know, there are over 600 form functions for "Run
Reports"
Question: Which responsibility do you need to extract Self Service
Personalizations?
Answer:Functional Administrator
Question: Can you list any one single limitation of Forms Personalization feature that was delivered with 11.5.10
Answer:You can not implement interactive messages, i.e. a message will give multiple options for Response. The best
you can get from Forms Personalization to do is popup up Message with OK option.
Question: You have just created two concurrent programs namely "XX PO Prog1" & "XX PO Prog2". Now you wish to
create a menu for Concurrent Request submission such that only these two Concurrent Programs are visible from that
Run Request menu. Please explain the steps to implement this?
Answer:
a) Define a request group, lets say with name "XX_PO_PROGS"
b) Add these two concurrent programs to the request group "XX_PO_PROGS"
c) Define a new Form Function that is attached to Form "Run Reports"
d) In the parameter field of Form Function screen, enter
REQUEST_GROUP_CODE="XX_PO_PROGS" REQUEST_GROUP_APPL_SHORT_NAME="XXPO"
TITLE="XXPO:XX_PO_PROGS"
e) Attach this form function to the desired menu.
Question: Does Oracle 10g support rule based optimization?
Answer: The official stance is that RBO is no longer supported by 10g.
Question: Does oracle support partitioning of tables in Oracle Apps?
Answer: Yes, Oracle does support partitioning of tables in Oracle Applications. There are several implementations
that partition on GL_BALANCES. However your client must buy licenses to if they desire to partition tables. To avoid the
cost of licensing you may suggest the clients may decide to permanently close their older GL Periods, such that historical
records can be archived.
Note: Before running the archival process the second time, you must clear down the archive table
GL_ARCHIVE_BALANCES (don’t forget to export archive data to a tape).
Question: What will be your partitioning strategy on GL_BALANCES? Your views please?
Answer: This really depends upon how many periods are regularly reported upon, how many periods are left open etc.
You can then decide to partition on period_name, or period ranges, or on the status of the GL Period.
Question: Does Oracle support running of gather stats on SYS schema in Oracle Apps?
Answer: If your Oracle Applications instance is on 10g, then you can decide to run stats for SYS schema. This can be
done by exec dbms_stats.gather_schema_stats('SYS');
Alternately using command dbms_stats.gather_schema_stats('SYS',cascade=>TRUE,degree=>20);
I will prefer the former with default values.
If you wish to delete the stats for SYS use exec dbms_stats.delete_schema_stats('SYS');
You can schedule a dbms_job for running stats for SYS schema.
Question: Can you use concurrent program "Gather Schema Statistics" to gather stats on sys schema in oracle
apps?
Answer: No, "Gather Schema Statistics" has no parameters for SYS schema. Please use dbms_job.
Question: Which table is used to provide drill down from Oracle GL into sub-ledger?
Answer: GL_IMPORT_REFERENCES
Question: What is the significance of profile option “Node Trust Level” in Oracle Apps.
Answer: If this profile option is set to a value of external against a server, then it signifies that the specific mid-tier is
External i.e. it will be exposed to the www. In other words this server is not within the firewall of your client. The idea
behind this profile option is to flag such middle-tier so that special restrictions can be applied against its security, which
means a very restricted set of responsibilities will be available from such Middle-Tier.
Question: What is the significance of profile option “Responsibility Trust Level”.
Answer: In order to make a responsibility accessible from an external web tier, you must set profile option
“Responsibility Trust Level” at responsibility level to “External”. Only those responsibilities that have this profile option
against them will be accessible from External Middle tiers.
Question: What else can you suggest to restrict the access to screens from external web tiers?
Answer: You may use URL filtering within Apache.
Question: What is the role of Document Manager in Oracle Purchasing?
Answer: POXCON is an immediate concurrent program. It receives pipe signal from the application when a request
is made for approval/reservations/receipts.
Question: How to debug a document manager in Oracle Apps?
Answer: Document manger runs within the concurrent manager in Oracle Applications. When an application uses a
Document Manager, it sends a pipe signal which is picked up by the document manager.
There are two mechanisms by which to trace the document manager
1. Set the debugging on by using profile option
STEP 1. Set profile option "Concurrent:Debug Flags" to TCTM1
This profile should only generate debugs when set at Site level(I think, as I have only tried site), because Document
Manager runs in a different session.
STEP 2. Bounce the Document Managers
STEP 3. Retry the Workflow to generate debugs.
STEP 4. Reset profile option "Concurrent:Debug Flags" to blank
STEP 5. have a look at debug information in table fnd_concurrent_debug_info
2. Enable tracing for the document managers
This can be done by setting profile option “Initialization SQL Statement – Custom” against your username before
reproducing the issue. The value of this profile will be set so as to enable trace using event 10046, level 12.
Question: You have written a Java Concurrent Program in Oracle Apps. You want to modify the CLASSPATH such
that new class CLASSPATH is effective just for this program.
Answer: In the options field of the concurrent program you can enter something similar to below.
-cp <your custom lib pathused by Java Conc
Prog> :/home/xxvisiondev/XXDEVDB/comn/java/appsborg.zip:/home/xxvisiondev/XXDEVDB/comn/java
Question: How will you open a bc4j package in jdeveloper?
Answer: Oracle ships a file named server.xml with each bc4j package.
You will need to ftp that file alongside other bc4j objects(VO’s, EO’s, AM,
Classes etc).
Opening the server.xml will load the complete package starting from
AM(application module). This is a mandatory step when building
Extensions to framework.
Question: In OA Framework Self-Service screen, you wish to disable a
tab. How will you do it?
Answer: Generally speaking, the tabs on a OA Framework page are
nothing but the SubMenus. By entering menu exclusion against the
responsibility, you can remove the tab from self service page.
Question: In self service, you wish to change the background color and
the foreground text of the OA Framework screens to meet your corporate
standards. How will you do it?
Answer: You will need to do the below steps
a….Go to Mid Tier, and open $OA_HTML/cabo/styles/custom.xss
b…Enter below text( change colours as needed)
<style name="DarkBackground">
<property name="background-color">#000066</property>
</style>
<style name="TextForeground">
<property name="color">#0000FF</property>
</style>
c… cd $OA_HTML/cabo/styles/cache
d…Take a backup of all the css files.
e…Delete all the files of following pattern oracle-desktop*.css
The idea here is to delete the cache. Next time when you logon to Oracle
Apps Self Service, the Framework will rebuild the css file if found missing
for your browser.
Question: Can you extend and substitue a root AM ( Application Module)
in OA Framework using JDeveloper.
Answer: You can extend the AM in jDeveloper, but it doesn’t work( at
least it didn’t work in 11.5.9). I am hopeful that Oracle will deliver a
solution to this in the future.
Question: In a workflow notification, you have a free text response field
where the user enters the Vendor Number for the new vendor. You want to
validate the value entered in the notification response field upon the
submission of a response. How will you do it?
Answer: You will need to attach a post notification function to the Workflow
Notification.
The PL/SQL code will look similar to below:-
The below code will display an error in the notification when user attempts
to create a Duplicate Vendor Number.
PROCEDURE validate_response_from_notif
(
itemtype IN VARCHAR2
,itemkey IN VARCHAR2
,actid IN NUMBER
,funcmode IN VARCHAR2
,RESULT IN OUT VARCHAR2
) IS
l_nid NUMBER;
l_activity_result_code VARCHAR2(200);
v_newly_entered_vendor_num VARCHAR2(50);
CURSOR c_get_response_for_new_vendor IS
SELECT wl.lookup_code
FROM wf_notification_attributes wna
,wf_notifications wn
,wf_message_attributes_vl wma
,wf_lookups wl
WHERE wna.notification_id = l_nid
AND wna.notification_id = wn.notification_id
AND wn.message_name = wma.message_name
AND wn.message_type = wma.message_type
AND wna.NAME = wma.NAME
AND wma.SUBTYPE = 'RESPOND'
AND wma.format = wl.lookup_type
AND wna.text_value = wl.lookup_code
AND wma.TYPE = 'LOOKUP'
AND decode(wma.NAME, 'RESULT', 'RESULT', 'NORESULT') = 'RESULT';
BEGIN
IF (funcmode IN ('RESPOND'))
THEN
l_nid := wf_engine.context_nid;
OPEN c_get_response_for_new_vendor;
FETCH c_get_response_for_new_vendor
INTO l_activity_result_code;
CLOSE c_get_response_for_new_vendor;
v_newly_entered_vendor_num :=
wf_notification.getattrtext(l_nid,'NEWLY_ENTERED_VENDOR_NUM_4_PO'
);
IF l_activity_result_code = 'NEW_VENDOR'
AND does_vendor_exist(p_vendor => v_newly_entered_vendor_num)
THEN
RESULT := 'ERROR: VendorNumber you entered already exists';
RETURN;
END IF;
END IF;
EXCEPTION
WHEN OTHERS THEN
RESULT := SQLERRM;
END validate_response_from_notif;
Question: How to make concurrent program end with warning?
Answer: If the concurrent program is of type PL/SQL, you can assign a
value of 1 to the “retcode” OUT Parameter.
For a Java Concurrent program, use the code similar to below
ReqCompletion lRC;
//get handle on request completion object for reporting status
lRC = pCpContext.getReqCompletion();
lRC.setCompletion(ReqCompletion.WARNING, "WARNING");
Question: How do you link a Host type concurrent program to Concurrent
Manager?
Answer: Assuming your executable script is LOADPO.prog, then use the
commands below
cd $XXPO_TOP/bin
ln -s $FND_TOP/bin/fndcpesr $XXPO_TOP/bin/LOADPO
Question: How do you know if a specific Oracle patch has been applied in
apps to your environment.
Answer: Use table ad_bugs, in which column bug_number is the patch
number.
SELECT bug_number
,to_char(creation_date, 'DD-MON-YYYY HH24:MI:SS') dated
FROM apps.ad_bugs
WHERE bug_number = TRIM('&bug_number') ;
Question: How do you send a particular Oracle Apps Workflow
Activity/Function within a workflow process into background mode.
Answer: If cost of the workflow activity is greater than 50, then the
workflow activity will be processed in background mode only, and it won’t
be processed in online mode.
Question: What are the various ways to kick-off a workflow
Answer: You can eiter use wf_engine.start_process or you can attach a
runnable process such ghat it subscribes to a workflow event.
Question: When starting (kicking off) an oracle workflow process, how do
you ensure that it happens in a background mode?
--a)if initiating the process using start_process, do the below
wf_engine.threshold := -1;
wf_engine.createprocess(l_itemtype
,l_itemkey
,'<YOUR PROCESS NAME>');
wf_engine.startprocess(l_itemtype, l_itemkey)
--B) When initiating the workflow process through an event subscription,
set the Execution Condition Phase to be equal to or above 100 for it to be
executed by background process.
Question: On 10g, how will you use awr?
Answer: By running below scripts. These are both the same scripts, but
with differing parameters.
$ORACLE_HOME/rdbms/admin/awrrpt.sql
$ORACLE_HOME/rdbms/admin/awrrpti.sql
Question : How will you configure Apache to run in Debug mode,
specifically usefull when debugging iProcurement ( prior to 11.5.10).
Answer: After 11.5.10, FND Logging can be used for debugging Oracle
iProcurement.
Prior to 11.5.10
----STEPS IN A NUTSHELL----cd $ORACLE_HOME/../iAS/Apache
vi $ORACLE_HOME/../iAS/Apache/Jserv/etc/ssp_init.txt
DebugOutput=/home/<<SID>>/ora9/iAS/Apache/Apache/logs/debug.log
DebugLevel=5
DebugSwitch=ON
vi $ORACLE_HOME/../iAS/Apache/Jserv/etc/jserv.conf
ApJServLogLevel debug
vi $ORACLE_HOME/../iAS/Apache/Jserv/etc/jserv.properties
log=true
Question: How will you add a new column to a List Of Values ( LOV ) in
Oracle Applications Framework? Can this be done without customization?
Answer: Yes, this can be done without customization, i.e. by using OA
Framework Extension coupled with Personalization. Implement the following
Steps :a) Extend the VO ( View Object ), to implement the new SQL required to
support the LOV.
b) Substitute the base VO, by using jpximport [ similar to as explained in
Link ]
c) Personalize the LOV Region, by clicking on Add New Item. While adding
the new Item, you will cross reference the newly added column to VO.
Question: Can you do fnd_request.submit_request from SQL Plus in Oracle?
Answer: You will need to initialize the global variables first using fnd_global.initialize
DECLARE
v_session_id INTEGER := userenv('sessionid') ;
BEGIN
fnd_global.initialize
(
SESSION_ID => v_session_id
,USER_ID => <your user id from fnd_user.user_id>
,RESP_ID => <You may use Examine from the screen PROFILE/RESP_ID>
,RESP_APPL_ID => <You may use Examine from the screen PROFILE/RESP_APPL_ID>
,SECURITY_GROUP_ID => 0
,SITE_ID => NULL
,LOGIN_ID => 3115003--Any number here
,CONC_LOGIN_ID => NULL
,PROG_APPL_ID => NULL
,CONC_PROGRAM_ID => NULL
,CONC_REQUEST_ID => NULL
,CONC_PRIORITY_REQUEST => NULL
);
commit ;
END ;
/
Optionally you may use fnd_global.apps_initialize, which internally calls fnd_global.initialize
fnd_global.apps_initialize(user_id => :user_id,
resp_id => :resp_id,
resp_appl_id => :resp_appl_id,
security_group_id => :security_group_id,
server_id => :server_id);
By doing the above, your global variables upon which Concurrent Managers depend upon will be populated. This will be
equivalent to logging into Oracle Apps and submitting the concurrent request from a responsibility.
Question: You are told that the certain steps in the Oracle Apps Form/Screen are running slow, and you are asked to
tune it. How do you go about it.
Answer: First thing to do is to enable trace. Preferably, enable the trace with Bind Variables. This can be done by
selecting menu Help/Diagnostics/Trace/”Trace With Binds and Wait”
Internally Oracle Forms issues a statement similar to below:alter session set events='10046 trace name context forever, level 12' ;
Enable Trace with Bind Variables in Apps
This will enable the trace with Bind Variable values being shown in the trace file.
The screen in Oracle Apps will also provide the name of the trace file which is located in directly identified by
select value from v$parameter where name like '%us%r%dump%'
Doing a tkprof with explain plan option, reviewing plans and stats in trace file can help identify the slow performing SQL.
Question: What is the difference between running Gather Stats and “Program – Optimizer[RGOPTM]” in Oracle
General Ledger?
Answer: “Gather Stats” will simply gather the stats against existing tables, indexes etc. However Gather Stats does
not create any new indexes. But “Program – Optimizer[RGOPTM]” can create indexes on GL_CODE_COMBINATIONS,
provided accounting segment has the indexed flag enabled,
Question: You have written a piece of code in POR_CUSTOM_PKG for Oracle iProcurement, but its not taking any
effect? What may be the reason?
Answer: Depending upon which procedure in POR_CUSTOM_PKG has been programmed, one or more of the
below profile options must be set to Yes
POR: Enable Req Header Customization
POR: Enable Requisition Line Customization
POR: Enable Req Distribution Customization
Question: What is the key benefit of punching out to suppliers catalogs rather than loading their catalogs locally in
Oracle iProcurement?
Answer: Punchout has several advantages like, Catalogs don’t need to be loaded locally saves space on your
system. You can get up-to-date list of catalogs by punching out and also you get the benefit of up-to-date pricing
information on vendor items.
Question: Does oracle have a test environment on exchange?
Answer: http://testexchange.oracle.com
Question: Does Oracle Grants use its own schema or does it uses Oracle Project Accounting schema?
Answer: Although Oracle Grants has its own schema i.e. GMS, it reuses many of the tables with in Oracle Projects
Schema like PA_PROJECTS_ALL, PA_EXPENDITURE_ITEMS_ALL, PA_EXPENDITURE_TYPES etc.
Question: How to make an Oracle Report Type concurrent program produce an excel friendly output?
Answer: Comma can be concatenated between the column values, however a better option is to create tab delimited
file, as it takes care of commas within the string.
For this, use SQL similar to below in the report
select 'a' || chr(9) || 'b' from dual;
Question: What are the settings needed for printing bitmap reports?
Answer: Get your DBA to configure two files i.e. uiprint.txt & default.ppd
For details, refer to Metalink Note 189708.1
Question: For a PL/SQL based concurrent program do you have to issue a commit at the end?
Answer: The concurrent program runs within its own new session. In APPS, the default database setting enforces a
commit at the end of each session. Hence no explicit COMMIT is required.
Question: What is the best way to add debugging to the code in apps?
Answer: Use fnd_log.string , i.e. FND Logging. Behind the scenes Oracles FND Logging uses autonomous transaction
to insert records in a table named fnd_log_messages.
For example
DECLARE
BEGIN
fnd_log.STRING(log_level => fnd_log.level_statement
,module => 'xxxx ' || 'pkg/procedurename '
,message => 'your debug message here');
END ;
Three profile options effecting FND Logging are
FND: Debug Log Mode
FND: Debug Log Enabled
FND: Debug Log Module
Question: If you wish to trigger of an update or insert in bespoke table or take some action in response to a TCA
record being created or modified, how would you do it? Will you write a database triggers on TCA Tables?
Answer: There are various pre-defined Events that are invoked from the Oracle TCA API’s.
TCA was Oracle’s first initiative towards a fully API based approach, which means the screen and the processes all use
the same set of APIs for doing same task.
In order to take an action when these events occur, you can subscribe a custom PL/SQL procedure or a Custom Workflow
to these events. Some of the important TCA events are listed below:oracle.apps.ar.hz.ContactPoint.update
oracle.apps.ar.hz.CustAccount.create
oracle.apps.ar.hz.CustAccount.update
oracle.apps.ar.hz.CustAcctSite.create
oracle.apps.ar.hz.CustAcctSite.update
oracle.apps.ar.hz.CustAcctSiteUse.create
oracle.apps.ar.hz.CustAcctSiteUse.update
oracle.apps.ar.hz.Location.create
oracle.apps.ar.hz.Location.update
oracle.apps.ar.hz.Organization.create
oracle.apps.ar.hz.Organization.update
oracle.apps.ar.hz.PartySite.create
oracle.apps.ar.hz.PartySite.update
oracle.apps.ar.hz.PartySiteUse.create
oracle.apps.ar.hz.PartySiteUse.update
oracle.apps.ar.hz.Person.create
oracle.apps.ar.hz.Person.update
Question: In Oracle OA Framework, is the MDS page/document definition stored in database or in the file system?
Answer: The MDS document details are loaded into database, in the following sets of tables.
JDR_ATTRIBUTES
JDR_ATTRIBUTES_TRANS
JDR_COMPONENTS
JDR_PATHS
The Document is loaded via XMLImporter, as detailed in XMLImporter Article
Question: In a Oracle Report data group, you have a “data link” between two queries. How do you ensure that the
data link is made Outer Joined?
Answer: The data link is an Outer Join by default.
Question: How does substitution work in OA Framework?
What are the benefits of using Substitution in OA Framework?
Answer: Based on the user that has logged into OA Framework, MDS defines the context of the logged in user. Based
upon this logged in context, all applicable personalization are applied by MDS. Given that substitutions are loaded as site
level personalizations, MDS applies the substituted BC4J objects along with the personalizations. The above listed steps
occur as soon as Root Application module has been loaded.
The benefit of using Substitution is to extend the OA Framework without customization of the underlying code. This is of
great help during Upgrades. Entity Objects and Validation Objects can be substituted. I think Root AM’s can’t be
substituted given that substitution kicks off after Root AM gets loaded.
Question: In OA Framework, once your application has been extended by substitutions, is it possible to revert back to
remove those substitutions?
Answer: yes, by setting profile option “Disable Self-Service Personal%” to Yes, keeping in mind that all your
personalizations will get disabled by this profile option. This profile is also very useful when debugging your OA
Framework based application in the event of some error. By disabling the personalization via profile, you can isolate the
error, i.e. is being caused by your extension/substitution code or by Oracle’s standard functionality.
Question: How can you import invoices into Oracle Receivables?
Answer: You can either use AutoInvoice by populating tables RA_INTERFACE_LINES_ALL,
RA_INTERFACE_DISTRIBUTIONS_ALL & RA_INTERFACE_SALESCREDITS_ALL.
Alternately you may decide to use API ar_invoice_api_pub.create_single_invoice for Receivables Invoice Import.
Question: How do you setup a context sensitive flexfield
Answer: Note: I will publish a white paper to sho step by step approach.
But for the purpose of your interview, a brief explanation is…a)Create a reference field, b) Use that reference field in
“Context Field” section of DFF Segment screen c) For each possible value of the context field, you will need to create one
record in section “Context Field Value” ( beneath the global data elements).
Question: Does Oracle iProcurement use same tables as Oracle Purchasing?
Answer: Yes, iProcurement uses the same set of requisition tables as are used by Core Purchasing.
Question: What is the name of the schema for tables in tca
Answer: AR (at least till 11.5.10, not sure about 11.5.10).
Question: Are suppliers a part of TCA?
Answer: Unfortunately not yet. However, Release 12 will be merging Suppliers into TCA.
Question: What is the link between order management and purchasing
Answer: Internal Requisitions get translated into Internal Sales Orders.
Question: How would you know if the purchase order XML has been transmitted to vendor, looking at the tables.
Answer: The XML delivery status can be found from a table named ecx_oxta_logmsg. Use the query below
SELECT edoc.document_number
,decode(eol.result_code, 1000, 'Success', 'Failure') AS status
,eol.result_text
FROM ecx_oxta_logmsg eol
,ecx_doclogs edoc
,ecx_outbound_logs eog
WHERE edoc.msgid = eol.sender_message_id
AND eog.out_msgid = edoc.msgid
ORDER BY edoc.document_number
Question: You have done forms personalization, now how will you move it from one environment to another?
Answer: Use FNDLOAD. For examples visit FNDLOAD Article
Question: What are the key benefits of forms personalization over custom.pll?
Answer:
-->Multiple users can develop forms personalization at any given point in time.
-->It is fairly easy to enable and disable forms personalizations.
-->A programmer is not required to do simple things such as hide/disable fields or buttons.
-->Provides more visibility on customizations to the screen.
Question: Tell me some limitations of forms personalization when compared to CUSTOM.pll?
Answer:
-->Can't create record group queries, hence can’t implement LOV Query changes.
-->Can't make things interactive, i.e. can’t have a message box that gives multiple choices for example Proceed or Stop
etc.
Question: Give me one example where apps uses partitioning?
Answer: WF_LOCAL_ROLES
Question: Give me one example of securing attributes in iProcurement.
Answer: You can define Realm to bundle suppliers into a Category. Such realm can then be assigned to the User
using Define User Screen. Security Attribute ICX_POR_REALM_ID can be used. By doing so, the user will only be made
visible those Punchout suppliers that belong to the realm against their securing attributes.
Question: Can you send blob attachments via workflow notifications?
Answer: Yes, you can send BLOB Attachments.
ORACLE DBA
Oracle DBA Interview Questions Answered: Technical
Last Updated on Thursday, 09 August 2012 15:18 | Hits: 49296
60 Oracle Database Administration (DBA) Interview Questions (Technical)
1. What is an Oracle Instance?
An Oracle database server consists of an Oracle database and an Oracle instance. Every time a
database is started, a system global area (SGA) is allocated and Oracle background processes
are started. The combination of the background processes and memory buffers is called an
Oracle instance. We can run multiple instances on the same Oracle Database Server, where
each instance connects to its database.
Oracle instance includes:
SGA - System or Shared Global Area
Components of SGA:



DBBC - Database Buffer Cache
SP - Shared Pool; divided into Library Cache (LC) and Data Dictionary Cache (DDC) or
Row Cache.
RLB - Redo log Buffer
Background Process (10/11g database):
Mandatory Processes








SMON - System Monitor
PMON - Process Monitor
DBWR - Database writer
LGWR - Log Writer
CKPT - Check point
RECO - Recoverer
DIAG - Diagnosability (new in 11g)
VKTM - Virtual keeper of time (keeps "SGA Time" variable in current, new in 11g)
Optional Process




ARCN - Archiver
MMAN - Memory Manager - ASMM
MMON - Memory Monitor
MMNL - Memory Monitor Light - AWR
3. When you start an Oracle DB which file is accessed first?
Oracle first opens and reads the initialization parameter file (init.ora)
[oracle@hostname ~]$ ls -la $ORACLE_HOME/dbs/initDB1_SID.ora
-rw-r--r-1
oracle
oinstall
1023
May
/u01/app/oracle/product/11.2.0/dbs/initDB1_SID.ora
10
19:27
4. What is the job of SMON and PMON processes?
SMON - System Monitor Process - Performs recovery after instance failure, monitors
temporary segments and extents; cleans temp segments, coalesces free space (mandatory
process for DB and starts by default)
PMON - Process Monitor - Recovers failed process resources. In Shared Server architecture,
monitors and retarts any failed dispatcher or server proceses (mandatory process for DB and
starts by default)
[oracle@hostname ~]$ ps -ef |grep -e pmon -e smon |grep -v grep
oracle 6755 1 0 12:59 ? 00:00:05 ora_pmon_DB1_SID
oracle 6779 1 0 12:59 ? 00:00:06 ora_smon_DB1_SID
5. What is Instance Recovery?
While Oracle instance fails, Oracle performs an Instance Recovery when the associated
database is being re-started.
Instance recovery occurs in two steps:
Cache recovery:
Changes being made to a database are recorded in the database buffer cache.
These changes are also recorded in online redo log files simultaneously. When there are
enough data in the database buffer cache,they are written to data files.
If an Oracle instance fails before the data in the database buffer cache are written to data files,
Oracle uses the data recorded in the online redo log files to recover the lost data when the
associated database is re-started.
This process is called cache recovery.
Transaction recovery:
When a transaction modifies data in a database, the before image of the modified data is
stored in an undo segment.
The data stored in the undo segment is used to restore the original values in case a
transaction is rolled back.
At the time of an instance failure, the database may have uncommitted transactions. It is
possible that changes made by these uncommitted transactions have gotten saved in data files.
To maintain read consistency, Oracle rolls back all uncommitted transactions when the
associated database is re-started.
Oracle uses the undo data stored in undo segments to accomplish this.
This process is called transaction recovery.
6. What is being written into the Redo Log Files?
Redo log records all changes made in datafiles.
In the Oracle database, redo logs comprise files in a proprietary format which log a history of
all changes made to the database. Each redo log file consists of redo records. A redo record,
also called a redo entry, holds a group of change-vectors, each of which describes or
represents a change made to a single block in the database.
Let's get into this topic a little bit dipper:
Log writer (LGWR) writes redo log buffer contents Into Redo Log FIles. LGWR does this every
three seconds, when the redo log buffer is 1/3 full and immediately before the Database
Writer (DBWn) writes its changed buffers into the datafile. The redo log of a database consists
of two or more redo log files. The database requires a minimum of two files to guarantee that
one is always available for writing while the
other is being archived (if the DB is in ARCHIVELOG mode). LGWR writes to redo log files in a
circular fashion. When the current redo log file fills, LGWR begins writing to the next available
redo log file. When the last available redo log file is filled, LGWR returns to the first redo log
file and writes to it, starting the cycle again.
Filled redo log files are available to LGWR for reuse depending on whether archiving is enabled.
•
If archiving is disabled (the database is in NOARCHIVELOG mode), a filled redo log file is
available after the changes recorded in it have been written to the datafiles.
If archiving is enabled (the database is in ARCHIVELOG mode), a filled redo log file is available
to LGWR after the changes recorded in it have been written to the datafiles and the file has
been archived.
Oracle Database uses only one redo log files at a time to store redo records written from the
redo log buffer. The redo log file that LGWR is actively writing to is called the current redo log
file. Redo log files that are required for instance recovery are called active redo log files. Redo
log files that are no longer required for instance recovery are called inactive redo log files.
If the database is in ARCHIVELOG mode it cannot reuse or overwrite an active online log file
until one of the archiver background processes (ARCn) has archived its contents.
If archiving is disabled (DB is in NOARCHIVELOG mode), then when the last redo log file is full,
LGWR continues by overwriting the first available active file.
A log switch is the point at which the database stops writing to one redo log file and begins
writing to another. Normally, a log switch occurs when the current redo log file is completely
filled and writing must continue to the next redo log file. However, you can configure log
switches to occur at regular intervals, regardless of whether the current redo log file is
completely filled. You can also force log switches manually.
Oracle Database assigns each redo log file a new log sequence number every time a log switch
occurs and LGWR begins writing to it.
When the database archives redo log files, the archived log retains its log sequence number.
7. How do you control number of Datafiles one can have in an Oracle database?
The db_files parameter is a "soft limit " parameter that controls the maximum number of
physical OS files that can map to an Oracle instance.
The maxdatafiles parameter is a different - "hard limit" parameter.
When issuing a "create database" command, the value specified for maxdatafiles is stored in
Oracle control files and default value is 32.
The maximum number of database files can be set with the init parameter db_files.
8. How many Maximum Datafiles can there be in Oracle Database?
Regardless of the setting of this paramter, maximum per database: 65533 (May be less on
some operating systems)
Maximum number of datafiles per tablespace: OS dependent = usually 1022
Limited also by size of database blocks and by the DB_FILES initialization parameter for a
particular instance
Bigfile tablespaces can contain only one file, but that file can have up to 4G blocks.
9. What is a Tablespace
A tablespace is a logical storage unit within an Oracle database.
Tablespace is not visible in the file system of the machine on which the database resides.
A tablespace, in turn, consists of at least one datafile which, in turn, are physically located in
the file system of the server.
A datafile belongs to exactly one tablespace. Each table, index and so on that is stored in an
Oracle database belongs to a tablespace.
The tablespace builds the bridge between the Oracle database and the filesystem in which the
table's or index' data is stored.
There are three types of tablespaces in Oracle:
 Permanent tablespaces
 Undo tablespaces
 Temporary tablespaces
10. What is the purpose of Redo Log files?
Before Oracle changes data in a datafile it writes these changes to the redo log.
If something happens to one of the datafiles, a backed up datafile can be restored and the
redo, that was written since, replied, which brings the datafile to the state it had before it
became unavailable.
11. Which default Database roles are created when you create a Database?
CONNECT , RESOURCE and DBA are three default roles. The DBA_ROLES data dictionary view
can be used to list all roles of a database and the authentication used for each role.
The following query lists all the roles in the database:
SELECT * FROM DBA_ROLES;
ROLE PASSWORD
---------------- -------CONNECT NO
RESOURCE NO
DBA NO
SECURITY_ADMIN YES
12. What is a Checkpoint?
A checkpoint occurs when the DBWR (database writer) process writes all modified buffers in
the SGA buffer cache to the database data files.
Data file headers are also updated with the latest checkpoint SCN, even if the file had no
changed blocks. Checkpoints occur AFTER (not during) every redo log switch and also at
intervals specified by initialization parameters.
Set parameter LOG_CHECKPOINTS_TO_ALERT=TRUE to observe checkpoint start and end
times in the database alert log.
Checkpoints can be forced with the ALTER SYSTEM CHECKPOINT; command.
SCN can refer to:
System Change Number - A number, internal to Oracle that is incremented over time as
change vectors are generated, applied, and written to the Redo log.
System Commit Number - A number, internal to Oracle that is incremented with each
database COMMIT.
Note: System Commit Numbers and System Change Numbers share the same internal
sequence generator.
13. Which Process reads data from Datafiles?
Server Process - There is no background process which reads data from datafile or database
buffer.
Oracle creates server processes to handle requests from connected user processes. A server
process communicates with the user process and interacts with Oracle to carry out requests
from the associated user process. For example, if a user queries some data not already in the
database buffers of the SGA, then the associated server process reads the proper data blocks
from the datafiles into the SGA.
Oracle can be configured to vary the number of user processes for each server process.
In a dedicated server configuration, a server process handles requests for a single user
process.
A shared server configuration lets many user processes share a small number of server
processes, minimizing the number of server processes and maximizing the use of available
system resources.
14. Which Process writes data in Datafiles?
Database Writer background process DBWn (20 possible) writes dirty buffers from the buffer
cache to the data files.
In other words, this process writes modified blocks permanently to disk.
15. Can you make a Datafile auto extendible. If yes, how?
YES. A Datafile can be auto extendible.
Here's how to enable auto extend on a Datafile:
SQL>alter database datafile '/u01/app/oracle/product/10.2.0/oradata/DBSID/EXAMPLE01.DBF'
autoextend on;
Note: For tablespaces defined with multiple data files (and partitioned table files), only the
"last" data file needs the autoextend option.
SQL>spool runts.sql
SQL>select 'alter database datafile '|| file_name|| ' '|| ' autoextend on;' from dba_data_files;
SQL>@runts
16. What is a Shared Pool?
The shared pool portion of the SGA contains the library cache, the dictionary cache, buffers for
parallel execution messages, and control structures. The total size of the shared pool is
determined by the initialization parameter SHARED_POOL_SIZE.
The default value of this parameter is 8MB on 32-bit platforms and 64MB on 64-bit platforms.
Increasing the value of this parameter increases the amount of memory reserved for the
shared pool.
17. What is kept in the Database Buffer Cache?
The database buffer cache is the portion of the SGA that holds copies of data blocks read from
datafiles.
All user processes concurrently connected to the instance share access to the database buffer
cache.
18. How many maximum Redo Logfiles one can have in a Database?
Maximum number of logfiles is limited by value of MAXLOGFILES parameter in the CREATE
DATABASE statement. Control file can be resized to allow more entries; ultimately an
operating system limit. Maximum number of logfiles per group - Unlimited
Consider the parameters that can limit the number of redo log files before setting up or
altering the configuration of an instance redo log.
The following parameters limit the number of redo log files that you can add to a database:
MAXLOGFILES & MAXLOGMEMBERS.
The MAXLOGFILES parameter used in the CREATE DATABASE statement determines the
maximum number of groups of redo log files for each database. Group values can range from
1 to MAXLOGFILES.
When the compatibility level is set earlier than 10.2.0, the only way to override this upper
limit is to re-create the database or its control file. Therefore, it is important to consider this
limit before creating a database.
When compatibility is set to 10.2.0 or later, you can exceed the MAXLOGFILES limit, and the
control files expand as needed.
If MAXLOGFILES is not specified for the CREATE DATABASE statement, then the database uses
an operating system specific default value.
The MAXLOGMEMBERS parameter used in the CREATE DATABASE statement determines the
maximum number of members for each group. As with MAXLOGFILES, the only way to
override this upper limit is to re-create the database or control file. Therefore, it is important
to consider this limit before creating a database.
If no MAXLOGMEMBERS parameter is specified for the CREATE DATABASE statement, then the
database uses an operating system default value.
19. What is difference between PFile and SPFile?
A PFILE is a static, text file located in $ORACLE_HOME/dbs - UNIX
An SPFILE (Server Parameter File) is a persistent server-side binary file that can only be
modified with the "ALTER SYSTEM SET" command.
20. What is PGA_AGGREGATE_TARGET parameter?
PGA_AGGREGATE_TARGET: specifies the target aggregate PGA memory available to all server
processes attached to the instance.
21. Large Pool is used for what?
The large pool is an optional memory area and provides large memory allocations for:
 Session memory for the shared server and the Oracle XA interface (used where
transactions interact with more than one database)
 I/O server processes, buffer area
 Oracle backup and restore operations (RMAN)
 User Global Area (UGA) for shared servers
22. What is PCT Increase setting?
PCTINCREASE refers to the percentage by which each next extent (beginning with the third
extend) will grow.
The size of each subsequent extent is equal to the size of the previous extent plus this
percentage increase.
Preventing tablespace fragmentation
Try to set PCTINCREASE to 0 or 100. Bizarre values for PCTINCREASE will contribute to
fragmentation.
For example if you set PCTINCREASE to 1 you will see that your extents are going to have
weird and wacky sizes: 100K, 100K, 101K, 102K, etc. Such extents of bizarre size are rarely
re-used in their entirety.
PCTINCREASE of 0 or 100 gives you nice round extent sizes that can easily be reused. Eg.
100K, 100K, 200K, 400K, etc.
Locally Managed tablespaces (available from Oracle 8i onwards) with uniform extent sizes
virtually eliminates any tablespace fragmentation.
Note that the number of extents per segment does not cause any performance issue anymore,
unless they run into thousands and thousands where additional I/O may be required to fetch
the additional blocks where extent maps of the segment are stored.
23. What is PCTFREE and PCTUSED Setting?
PCTFREE is a block storage parameter used to specify how much space should be left in a
database block for future updates.
For example, for PCTFREE=10, Oracle will keep on adding new rows to a block until it is 90%
full. This leaves 10% for future updates (row expansion).
When using Oracle Advanced Compression, Oracle will trigger block compression when the
PCTFREE is reached. This eliminates holes created by row deletions and maximizes contiguous
free space in blocks.
See the PCTFREE setting for a table:
SQL> SELECT pct_free FROM user_tables WHERE table_name = 'EMP';
PCT_FREE
---------10
PCTUSED is a block storage parameter used to specify when Oracle should consider a
database block to be empty enough to be added to the freelist. Oracle will only insert new
rows in blocks that is enqueued on the freelist.
For example, if PCTUSED=40, Oracle will not add new rows to the block unless sufficient rows
are deleted from the block so that it falls below 40% empty.
24. What is Row Migration and Row Chaining?
Row Migration refers to rows that were moved to another blocks due to an update making
them too large to fit into their original blocks.
Oracle will leave a forwarding pointer in the original block so indexes will still be able to "find"
the row. Note that Oracle does not discriminate between chained and migrated rows, even
though they have different causes. A chained row is a row that is too large to fit into a single
database data block.
For example, if you use a 4KB blocksize for your database, and you need to insert a row of
8KB into it, Oracle will use 3 blocks and store the row in pieces.
Some conditions that will cause row chaining are:
 Tables whose row size exceeds the blocksize
 Tables with long and long raw columns are prone to having chained rows
 Tables with more then 255 columns will have chained rows as Oracle break wide tables
up into pieces.
Detecting row chaining:
This query will show how many chained (and migrated) rows each table has:
SQL>SELECT owner, table_name, chain_cnt FROM dba_tables WHERE chain_cnt > 0;
To see which rows are chained:
SQL>ANALYZE TABLE tablename LIST CHAINED ROWS;
This will put the rows into the INVALID_ROWS table which is created by the utlvalid.sql script
(located in $ORACLE_HOME/rdbms/admin).
25. What is ORA-01555 - Snapshot Too Old error and how do you avoid it?
The ORA-01555 is caused by Oracle read consistency mechanism. If you have a long running
SQL that starts at 11:30 AM, Oracle ensures that all rows are as they appeared at 11:30 AM,
even if the query runs until noon!
Oracles does this by reading the "before image" of changed rows from the online undo
segments. If you have lots of updates, long running SQL and too small UNDO, the ORA-01555
error will appear. ORA-01555 error relates to insufficient undo storage or a too small value for
the undo_retention parameter:
ORA-01555: snapshot too old: rollback segment number string with name "string" too small
Cause: Rollback records needed by a reader for consistent read are overwritten by other
writers.
Action: If in Automatic Undo Management mode, increase the setting of UNDO_RETENTION.
Otherwise, use larger rollback segments.
You can get an ORA-01555 error with a too-small undo_retention, even with a large undo
tables.
However, you can set a super-high value for undo_retention and still get an ORA-01555 error.
The ORA-01555 snapshot too old error can be addressed by several remedies:
 Re-schedule long-running queries when the system has less DML load
 Increasing the size of your rollback segment (undo) size
 The ORA-01555 snapshot too old also relates to your setting for automatic undo
retention
 Don't fetch between commits
26. What is a Locally Managed Tablespace?
Locally Managed Tablespace is a tablespace that record extent allocation in the tablespace
header.
Each tablespace manages it's own free and used space within a bitmap structure stored in one
of the tablespace's data files.
Advantages of Locally Managed Tablespaces:




Eliminates the need for recursive SQL operations against the data dictionary
(UET$ and FET$ tables)
Reduce contention on data dictionary tables (single ST enqueue)
Locally managed tablespaces eliminate the need to periodically coalesce free space
(automatically tracks adjacent free space)
Changes to the extent bitmaps do not generate rollback information
27. Can you audit SELECT statements?
YES. But beware, you will need a storage mechanism to hold your SQL SELECT audits, a high
data volume that can exceed the size of your whole database, everyday.
SQL SELECT auditing can be accomplished in several ways:


Oracle audit table command: audit SELECT table by FRED by access;
Oracle Fined-grained Auditing
In a busy database, the volume of the SELECT audit trail could easily exceed the size of the
database every data.
Plus, all data in the audit trail must also be audited to see who has selected data from the
audit trail.
28. What does DBMS_FGA package do?
The DBMS_FGA package provides fine-grained security functions. DBMS_FGA is a PL/SQL
package used to define Fine Grain Auditing on objects.
DBMS_FGA Package Subprograms:




ADD_POLICY Procedure - Creates an audit policy using the supplied predicate as the
audit condition
DISABLE_POLICY Procedure - Disables an audit policy
DROP_POLICY Procedure - Drops an audit policy
ENABLE_POLICY Procedure - Enables an audit policy
29. What is Cost Based Optimization?
The Oracle Cost Based Optimizer (CBO) is a SQL Query optimizer that uses data statistics to
identify the query plan with lowest cost before execution. The cost is based on the number of
rows in a table, index efficiency, etc.
All applications should be converted to use the Cost Based Optimizer as the Rule Based
Optimizer is not be supported in Oracle 10g and above releases.
30. How often you should collect statistics for a table?
Analyse if it's necessary!
- Refresh STALE statistics before the batch processes run but only for tables involved in batch
run,
- Don't do it if you don't have to.
- Oracle databse has default, scheduled job "gather_stats_job" that analyses stats on a daily
basis during the maintenance window time.
31. How do you collect statistics for a table, schema and Database?
Using DBMS_STATS package to gather Oracle dictionary statistics.
HOW-TO: http://emarcel.com/database/157-dbmsstats10g
32. Can you make collection of Statistics for tables automatically?
YES. Oracle databse has default, scheduled job "gather_stats_job" that analyses stats on a
daily basis during the maintenance window time.
There are two scheduled activities related to the collection of Oracle "statistics":


AWR statistics: Oracle has an automatic method to collect AWR "snapshots" of data
that is used to create elapsed-time performance reports.
Optimizer statistics: Oracle has an automatic job to collect statistics to help the
optimizer make intelligent decisions about the best access method to fetch the desired
rows.
This
job
can
be
disabled
with
this
command:
dbms_scheduler.disable(’SYS.GATHER_STATS_JOB’);
Oracle collects optimizer statistics for SQL via the default of autostats_target = auto.
exec
33. On which columns you should create Indexes?
In general, you should create an index on a column in any of the following situations:



The column is queried frequently
A referential integrity constraint exists on the column
A UNIQUE key integrity constraint exists on the column
The following list gives guidelines in choosing columns to index:




You should create indexes on columns that are used frequently in WHERE clauses
Are used frequently to join tables
Are used frequently in ORDER BY clauses
On columns that have few of the same values or unique values in the table
34. What type of Indexes are available in Oracle?
There are many index types within Oracle:
B*Tree Indexes - common indexes in Oracle. They are similar construct to a binary tree,
they provide fast access by key, to an individual row or range of rows, normally requiring very
few reads to find the correct row.
The B*Tree index has several subtypes:




Index Organised Tables - A table stored in a B*Tree structure
B*Tree Cluster Indexes - They are used to index the cluster keys
Reverse Key Indexes - The bytes in the key are reversed. This is used to stop
sequential keys being on the same block like 999001, 999002, 999003 would be
reversed to 100999, 200999, 300999 thus these would be located on different blocks.
Descending Indexes - They allow data to be sorted from big to small (descending)
instead of small to big (ascending).
Bitmap Indexes - With a bitmap index , a single index entry uses a bitmap to point to many
rows simultaneously, they are used with low data that is mostly read-only. Schould be avoided
in OLTP systems.
Function Based Indexes - These are B*Tree or bitmap indexes that store the computed
result of a function on a row(s) (for example sorted results)- not the column data itself.
Application Domain Indexes - These are indexes you build and store yuorself, either in
Oracle or outside of Oracle
interMedia Text Indexes - This is a specialised index built into Oracle to allow for keyword
searching of large bodies of text.
35. What is B-Tree Index?
A B-Tree index is a data structure in the form of a tree, but it is a tree of database blocks, not
rows.
Note: "B" is not for binary; it's balanced.
36. A table is having few rows, should you create indexes on this table
Small tables do not require indexes; if a query is taking too long, then the table might have
grown from small to large.
You can create an index on any column; however, if the column is not used in any of these
situations, creating an index on the column does not increase performance and the index
takes up resources unnecessarily.
37. A Column is having many repeated values which type of index you should create
on this column, if you have to?
For example, assume there is a motor vehicle database with numerous low-cardinality
columns such as car_color, car_make, car_model, and car_year. Each column contains less
than 100 distinct values by themselves, and a b-tree index would be fairly useless in a
database of 20 million vehicles.
38. When should you rebuilt indexes?
In 90% cases - NEVER.
When the data in index is sparse (lots of holes in index, due to deletes or updates) and your
query is usually range based.
Also index blevel is one of the key indicators of performance of sql queries doing Index range
scans.
39. Can you built indexes online?
YES. You can create and rebuild indexes online.
This enables you to update base tables at the same time you are building or rebuilding indexes
on that table.
You can perform DML operations while the index build is taking place, but DDL operations are
not allowed.
Parallel execution is not supported when creating or rebuilding an index online.
The following statements illustrate online index build operations:
CREATE INDEX emp_name ON emp (mgr, emp1, emp2, emp3) ONLINE;
40. Can you see Execution Plan of a statement?
YES. In many ways, for example from GUI based tools like TOAD, Oracle SQL Developer.
Configuring AUTOTRACE, a SQL*Plus facility
AUTOTRACE is a facility within SQL*Plus to show us the explain plan of the queries we've
executed, and the resources they used.
Once the PLAN_TABLE has been installed in the database, You can control the report by
setting the AUTOTRACE system variable.



SET AUTOTRACE OFF - No AUTOTRACE report is generated. This is the default.
SET AUTOTRACE ON EXPLAIN - The AUTOTRACE report shows only the optimizer
execution path.
SET AUTOTRACE ON STATISTICS - The AUTOTRACE report shows only the SQL
statement execution statistics.


SET AUTOTRACE ON - The AUTOTRACE report includes both the optimizer execution
path and the SQL statement execution statistics.
SET AUTOTRACE TRACEONLY - Like SET AUTOTRACE ON, but suppresses the printing
of the user's query output, if any.
41. A table has been created with below settings. What will be size of 4th extent?
storage (initial 200k
next 200k
minextents 2
maxextents 100
pctincrease 40)
What will be size of 4th extent?
"NEXT" Specify in bytes the size of the next extent to be allocated to the object.
Percent Increase allows your segment to grow at an increasing rate.
The first two extents will be of a size determined by the Initial and Next parameter (200k)
The third extent will be 1 + PCTINCREASE/100 times the second extent (1,4*200=280k).
AND The fourth extent will
(1,4*280=392k!!!), and so on...
be
1
+
PCTINCREASE/100
times
the
third
extent
42. What is DB Buffer Cache Advisor?
The Buffer Cache Advisor provides advice on how to size the Database Buffer Cache to obtain
optimal cache hit ratios.
Member of Performance Advisors --> Memory Advisor pack.
43. What is STATSPACK tool?
STATSPACK is a performance diagnosis tool provided by Oracle starting from Oracle 8i and
above.
STATSPACK is a diagnosis tool for instance-wide performance problems; it also supports
application tuning activities by providing data which identifies high-load SQL statements.
Although AWR and ADDM (introduced in Oracle 10g) provide better statistics than STATSPACK,
users that are not licensed to use the Enterprise Manager Diagnostic Pack should continue to
use statspack.
More
information
about
STATSPACK,
can
be
found
in
file
$ORACLE_HOME/rdbms/admin/spdoc.txt.
44. Can you change SHARED_POOL_SIZE online?
YES. That's possible.
SQL>alter system set shared_pool_size=500M scope=both;
System altered.
It's a lot quicker to bounce the instance when changing this.
45. Can you Redefine a table Online?
Yes you can. In any database system, it is occasionally necessary to modify the logical or
physical structure of a table to:



Improve the performance of queries or DML
Accommodate application changes
Manage storage
Oracle Database provides a mechanism to make table structure modifications without
significantly affecting the availability of the table.
The mechanism is called online table redefinition.
When a table is redefined online, it is accessible to both queries and DML during much of the
redefinition process.
The table is locked in the exclusive mode only during a very small window that is independent
of the size of the table and complexity of the redefinition, and that is completely transparent
to users.
Online table redefinition requires an amount of free space that is approximately equivalent to
the space used by the table being redefined. More space may be required if new columns are
added.
You can perform online table redefinition with the Enterprise Manager Reorganize Objects
wizard or with the DBMS_REDEFINITION package.
46. Can you assign Priority to users?
YES. This is achievable with Oracle Resource Manager.
DBMS_RESOURCE_MANAGER is the packcage to administer the Database Resource Manager.
The DBMS_RESOURCE_MANAGER package maintains plans, consumer groups, and plan
directives. It also provides semantics so that you may group together changes to the plan
schema.
47. You want users to change their passwords every 2 months. How do you enforce
this?
Oracle password security is implemented via Oracle "profiles" which are assigned to users.
PASSWORD_LIFE_TIME - limits the number of days the same password can be used for
authentication
First, start by creating security "profile" in Oracle database and then alter the user to belong
to the profile group.
1) creating a profile:
create profile all_users
limit
PASSWORD_LIFE_TIME 60
PASSWORD_GRACE_TIME 10
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_REUSE_MAX 0
FAILED_LOGIN_ATTEMPTS 3
PASSWORD_LOCK_TIME UNLIMITED;
2) Create user and assign user to the all_users profile
SQL>create user chuck identified by norris profile all_users;
3) To "alter profile" parameter, say; change to three months:
SQL>alter profile all_users set PASSWORD_LIFE_TIME = 90;
48. How do you delete duplicate rows in a table?
There is a few ways to achieve that:

Using subquery to delete duplicate rows:
DELETE FROM table_name WHERE rowid NOT IN (SELECT max(rowid) FROM table_name
GROUP BY id);
More ways:




Use RANK to find and remove duplicate table rows
Use self-join to remove duplicate rows
Use analytics to detect and remove duplicate rows
Delete duplicate table rows that contain NULL values
source: http://www.dba-oracle.com/t_delete_duplicate_table_rows.htm
49. What is Automatic Management of Segment Space setting?
Oracle9i New Feature Series: Automatic Segment Space Management
Automatic Segment Space Management (ASSM) introduced in Oracle9i is an easier way of
managing space in a segment using bitmaps.
It eliminates the DBA from setting the parameters pctused, freelists, and freelist groups.
ASSM can be specified only with the locally managed tablespaces (LMT).
Oracle uses bitmaps to manage the free space. Bitmaps allow Oracle to manage free space
more automatically.
Here is an example:
CREATE TABLESPACE example
DATAFILE '/oradata/ORA_SID/example01.dbf' SIZE 50M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 2M
SEGMENT SPACE MANAGEMENT AUTO;
The storage parameters PCTUSED, FREELISTS and FREELIST GROUPS specified while creating
a table are ignored by Oracle on a LMT ASSM tablespace. Oracle does not produce an error.
One huge benefit of having ASSM is to reduce the “Buffer Busy Waits” you see on segments.
Beware:
Using ASSM can hinder database DML performance, and most Oracle experts will use manual
freelists and freelist groups.
50. What is the difference between DELETE and TRUNCATE statements?
The DELETE command is used to remove rows from a table. A WHERE clause can be used to
only remove some rows.
If no WHERE condition is specified, all rows will be removed. After performing a DELETE
operation you need to COMMIT or ROLLBACK the transaction to make the change permanent
or to undo it.
DELETE will cause all DELETE triggers on the table to fire.
TRUNCATE removes all rows from a table. A WHERE clause is not permited. The operation
cannot be rolled back and no triggers will be fired.
As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.
51. What is COMPRESS and CONSISTENT setting in EXPORT utility?
COMPRESS
Simply: COMPRESS=n - Allocated space in database for imported table will be exactly as the
space required to hold the data.
COMPRESS=y - The INITIAL extent of the table would be as large as the sum of all the extents
allocated to the table in the original database.
In other words:
The default, COMPRESS=y, causes Export to flag table data for consolidation into one initial
extent upon import.
If extent sizes are large (for example, because of the PCTINCREASE parameter), the allocated
space will be larger than the space required to hold the data.
If you specify COMPRESS=n, Export uses the current storage parameters, including the values
of initial extent size and next extent size.
If you are using locally managed tablespaces you should always export with COMPRESS=n
An
example:
http://oracleadmins.wordpress.com/2008/08/05/understanding-compressparameter-in-export
CONSISTENT
Default: n. Specifies whether or not Export uses the SET TRANSACTION READ ONLY statement
to ensure that the data seen by Export is consistent to a single point in time and does not
change during the execution of the exp command.
You should specify CONSISTENT=y when you anticipate that other applications will be
updating the target data after an export has started.
If you use CONSISTENT=n, each table is usually exported in a single transaction. However, if
a table contains nested tables, the outer table and each inner table are exported as separate
transactions.
If a table is partitioned, each partition is exported as a separate transaction.
Therefore, if nested tables and partitioned tables are being updated by other applications, the
data that is exported could be inconsistent. To minimize this possibility, export those tables at
a time when updates are not being done.
52. What is the difference between Direct Path and Conventional Path loading?
A conventional path load executes SQL INSERT statements to populate tables in an Oracle
database.
A direct path load eliminates much of the Oracle database overhead by formatting Oracle data
blocks and writing the data blocks directly to the database files.
more
info:
http://download.oracle.com/docs/cd/B10500_01/server.920/a96652/ch09.htm#1007504
53. Can you disable and enable Primary key?
You can use the ALTER TABLE statement to enable, disable, modify, or drop a constraint.
When the database is using a UNIQUE or PRIMARY KEY index to enforce a constraint, and
constraints associated with that index are dropped or disabled, the index is dropped, unless
you specify otherwise.
While enabled foreign keys reference a PRIMARY or UNIQUE key, you cannot disable or drop
the PRIMARY or UNIQUE key constraint or the index.
Disabling Enabled Constraints
The following statements disable integrity constraints. The second statement specifies that the
associated indexes are to be kept.
ALTER TABLE dept DISABLE CONSTRAINT dname_ukey;
ALTER TABLE dept DISABLE PRIMARY KEY KEEP INDEX, DISABLE UNIQUE (dname, loc) KEEP
INDEX;
The following statements enable novalidate disabled integrity constraints:
ALTER TABLE dept ENABLE NOVALIDATE CONSTRAINT dname_ukey;
ALTER TABLE dept ENABLE NOVALIDATE PRIMARY KEY, ENABLE NOVALIDATE UNIQUE (dname,
loc);
The following statements enable or validate disabled integrity constraints:
ALTER TABLE dept MODIFY CONSTRAINT dname_key VALIDATE;
ALTER TABLE dept MODIFY PRIMARY KEY ENABLE NOVALIDATE;
The following statements enable disabled integrity constraints:
ALTER TABLE dept ENABLE CONSTRAINT dname_ukey;
ALTER TABLE dept ENABLE PRIMARY KEY, ENABLE UNIQUE (dname, loc);
To disable or drop a UNIQUE key or PRIMARY KEY constraint and all dependent FOREIGN KEY
constraints in a single step, use the CASCADE option of the DISABLE or DROP clauses.
For example, the following statement disables a PRIMARY KEY constraint and any FOREIGN
KEY constraints that depend on it:
ALTER TABLE dept DISABLE PRIMARY KEY CASCADE;
54. What is an Index Organized Table?
An index-organized table (IOT) is a type of table that stores data in a B*Tree index structure.
Normal relational tables, called heap-organized tables, store rows in any order (unsorted). In
contrast to this, index-organized tables store rows in a B-tree index structure that is logically
sorted in primary key order. Unlike normal primary key indexes, which store only the columns
included in it definition, IOT indexes store all the columns of the table (an exception to this
rule - is being called the overflow area).
Properties and restrictions:




An IOT must contain a primary key
Rows are accessed via a logical rowid and not a physical rowid like in heap-organized
tables
An IOT cannot be in a cluster
An IOT cannot contain a column of LONG data type

You cannot modify an IOT index property using ALTER INDEX (error ORA-25176), you
must use an ALTER TABLE instead.
Advantages of an IOT





As an IOT has the structure of an index and stores all the columns of the row,
accesses via primary key conditions are faster as they don't need to access the table
to get additional column values.
As an IOT has the structure of an index and is thus sorted in the order of the primary
key, accesses of a range of primary key values are also faster.
As the index and the table are in the same segment, less storage space is needed.
In addition, as rows are stored in the primary key order, you can further reduce space
with key compression.
As all indexes on an IOT uses logical rowids, they will not become unusable if the table
is reorganized.
Row overflow area
If some columns of the table are infrequently accessed, it is possible to offload them into
another segment named the overflow area. An overflow segment will decrease the size of the
main (or top) segment and will increase the performance of statements that do not need
access the columns in the overflow area.
Notes:
The overflow area can contains only columns that are not part of the primary key.
If a row cannot fit in a block, you must define an overflow area.
Consequently, the primary key values of an IOT must fit in a single block.
The columns of the table that are recorded in the overflow segment are defined using the
PCTHRESHOLD and/or INCLUDING options of the OVERFLOW clause (examples on source
website).
source: http://www.orafaq.com/wiki/Index-organized_table
55. What is a Global Index and Local Index?
Local Index - each partition of a local index is associated with exactly one partition of the
table.
Global Index - global index is associated with multiple partitions of the table.
Oracle offers two types of global partitioned index:
- Global Range Partitioned Indexes
- Global Hash Partitioned Indexes
Global Nonpartitioned Indexes - behave just like a nonpartitioned index.
Download