You are on page 1of 6

Imp Oracle PLSQL Interview Questions

I have taken more than 100 interviews for oracle plsql developer position and Below few set of questions i
asked in interviews.
RE: What is Pragma EXECPTION_INIT ? Explain...
Pragma exception_init Allow you to handle the Oracle predefined message by you'r own message. means you
can instruct compilertoassociatethe specific message to oracle predefined message at compile time.This way
you Improve the Readbility of your program,and handle it accoding to your own way.
It should be declare at the DECLARE section.
example
declare
salary number;
FOUND_NOTHING exception;
Pragma exception_init(FOUND_NOTHING ,100);
begin
select sal in to salaryfrom emp where ename ='ANURAG';
dbms_output.put_line(salary);
exception
WHEN FOUND_NOTHING THEN
dbms_output.put_line(SQLERRM);
end;
RE: What is Data Concarency and Consistency?
Concurrency
How well can multiple sessions access the same data simultaneously
Consistency
How consistent is the view of the data between and within multiple sessions, transactions or statements

RE: What is bulk binding please explain me in brief ?


Bulk Binds (BULK COLLECT , FORALL ) are a PL/SQL technique where, instead of multiple individual SELECT,
INSERT, UPDATE or DELETE statements are executed to retrieve from, or store data in, at table, all of the
operations are carried out at once, in bulk.
This avoids the context-switching you get when the PL/SQL engine has to pass over to the SQL engine, then
back to the PL/SQL engine, and so on, when you individually access rows one at a time. To do bulk binds with
Insert, Update and Delete statements, you enclose the SQL statement within a PL/SQL FORALL statement.
To do bulk binds with Select statements, you include the Bulk Collect INTO a collection clause in the SELECT
Statement instead of using Simply into .
Collections, BULK COLLECT and FORALL are the new features in Oracle 8i, 9i and 10g PL/SQL that can really
make a different to you PL/SQL performance
RE: what is p-code and sourcecode ?
P-code is Pre-complied code stored in Public cache memory of System Global Area after the Oracle instance
is started, whereas sourcecode is a simple code of sp, package, trigger, functions etc which are stored in
Oracle system defined data dictionary. Every session of oracle access the p-code which have the Execute
permission on that objects.
Source code stored in user_objects data dictinary for user defined Store proc, Trigger, Package, Function.
DBA_object stores all the db objects in sp. DB. ALL_objects stores all the db objects in sp. schema

According to O Reilly Book , the main difference between Index-By Table(pl-Sql Table) , Varray and nested
tables are Index-By Table
Nested Table
VARRAY
Dimensionality
Single
Single
Single
Usable in SQL?
No
Yes
Yes
Usable as column datatype in a table?
No
Yes; data stored "out of line" (in separate table)
Yes; data stored "in line" (in same table)
Uninitialized state
Empty (cannot be null); elements undefined
Atomically null; illegal to reference elements
Atomically null; illegal to reference elements
Initialization
Automatic, when declared
Via constructor, fetch, assignment
Via constructor, fetch, assignment
In PL/SQL, elements referenced via
BINARY_INTEGER
(-2,147,483,647 .. 2,147,483,647)
Positive integer between 1 and 2,147,483,647
Positive integer between 1 and 2,147,483,647
Sparse?
Yes
Initially, no; after deletions, yes
No
Bounded?
No
Can be extended
Yes
Can assign value to any element at any time?
Yes
No; may need to EXTEND first
No; may need to EXTEND first, and cannot EXTEND past upper bound
Means of extending
Assign value to element with a new subscript
Use built-in EXTEND procedure (or TRIM to condense), with no predefined maximum
EXTEND (or TRIM), but only up to declared maximum size
Can be compared for equality?
No
No
No
Retains ordering and subscripts when stored in and retrieved from database?
N/A
No
Yes

RE: What is autonomous Transaction? Where are they use...


Autonomous transaction is the transaction which acts independantly from the calling part and could commit
the process done.
example using prgma autonomous incase of mutation problem happens in a trigger
RE: why do we need to create a force view?what is its ...
It is some times important to create a view even if the base table does not exist and we are planning to
create one but not yet decided the structure, in that case one can create force view. This view can not be
accessed and it will be in 'invalid' state unless and untill you will create a base table and compile the force
view.
RE:Explain materialized views and how they are used.
Materialized views are objects that are reduced sets of information that have been summarized, grouped, or
aggregated from base tables. They are typically used in data warehouse or decision support systems.
RE:When a user process fails, what background process cleans up after it?
PMON
RE: How can you enable a trace for a session?
Use the DBMS_SESSION.SET_SQL_TRACE or
Use ALTER SESSION SET SQL_TRACE = TRUE;
Few other interview questions
1.What are the various types of Exceptions ?
User defined and Predefined Exceptions.
2.Can we define exceptions twice in same block ?
No.
3.What is the difference between a procedure and a function ?
Functions return a single variable by value whereas procedures do not return any variable by value. Rather
they return multiple variables by passing variables by reference through their OUT parameter.
4.Can you have two functions with the same name in a PL/SQL block ?
Yes.
5.Can you have two stored functions with the same name ?
Yes.
6.Can you call a stored function in the constraint of a table ?
No.
7.What are the various types of parameter modes in a procedure ?
IN, OUT AND INOUT.
8.What is Over Loading and what are its restrictions ?
OverLoading means an object performing different functions depending upon the no. of parameters or the
data type of the parameters passed to it.
9.Can functions be overloaded ?
Yes.
10.Can 2 functions have same name & input parameters but differ only by return datatype
No.

11.What are the constructs of a procedure, function or a package ?


The constructs of a procedure, function or a package are :
variables and constants cursors exceptions
12.Why Create or Replace and not Drop and recreate procedures ?
So that Grants are not dropped.
13.Can you pass parameters in packages ? How ?
Yes. You can pass parameters to procedures or functions in a package.
14.What are the parts of a database trigger ?
The parts of a trigger are: A triggering event or statement A trigger restriction A trigger action
15.What are the various types of database triggers ?
There are 12 types of triggers, they are combination of :Insert, Delete and Update Triggers.Before and After
Triggers.Row and Statement Triggers.(3*2*2=12)
16.What is the advantage of a stored procedure over a database trigger ?
We have control over the firing of a stored procedure but we have no control over the firing of a trigger.
17.What is the maximum no. of statements that can be specified in a trigger statement ?
One.
18.Can views be specified in a trigger statement ?No
19.What are the values of :new and :old in Insert/Delete/Update Triggers ?
INSERT : new = new value, old = NULLDELETE : new = NULL, old = old valueUPDATE : new = new value, old =
old value
20.What are cascading triggers? What is the maximum no of cascading triggers at a time?
When a statement in a trigger body causes another trigger to be fired, the triggers are said to be cascading.
Max = 32.
21.What are mutating triggers ?
A trigger giving a SELECT on the table on which the trigger is written.
22.What are constraining triggers ?
A trigger giving an Insert/Updat e on a table having referential integrity constraint on the triggering table.
23.Describe Oracle database's physical and logical structure ?
Physical : Data files, Redo Log files, Control file.Logical : Tables, Views, Tablespaces, etc.
24.Can you increase the size of a tablespace ? How ?
Yes, by adding datafiles to it.
25.Can you increase the size of datafiles ? How ?
No (for Oracle 7.0)Yes (for Oracle 7.3 by using the Resize clause ----- Confirm !!).
26.What is the use of Control files ?
Contains pointers to locations of various data files, redo log files, etc.
27.What is the use of Data Dictionary ?

Used by Oracle to store information about various physical and logical Oracle structures e.g. Tables,
Tablespaces, datafiles, etc
28.What are the advantages of clusters ?
Access time reduced for joins.
29.What are the disadvantages of clusters ?
The time for Insert increases.
30.Can Long/Long RAW be clustered ?No.
31.Can null keys be entered in cluster index, normal index ?Yes.
32.Can Check constraint be used for self referential integrity ? How ?
Yes. In the CHECK condition for a column of a table, we can reference some other column of the same table
and thus enforce self referential integrity.
33.What are the min. extents allocated to a rollback extent ?
Two
34.What are the states of a rollback segment ? What is the difference between partly available and needs
recovery ?
The various states of a rollback segment are :ONLINE, OFFLINE, PARTLY AVAILABLE, NEEDS RECOVERY and
INVALID.
35.What is the difference between unique key and primary key ?
Unique key can be null; Primary key cannot be null.
36.An insert statement followed by a create table statement followed by rollback ? Will the rows be inserted
?
No.
37.Can you define multiple savepoints ?
Yes.
38.Can you Rollback to any savepoint ?Yes.
40.What is the maximum no. of columns a table can have ?
254.
41.What is the significance of the & and && operators in PL SQL ?
The & operator means that the PL SQL block requires user input for a variable. The && operator means that
the value of this variable should be the same as inputted by the user previously for this same variable.If a
transaction is very large, and the rollback segment is not able to hold the rollback information, then will the
transaction span across different rollback segments or will it terminate ?It will terminate (Please check ).
42.Can you pass a parameter to a cursor ?Explicit cursors can take parameters, as the example below shows.
A cursor parameter can appear in a query wherever a constant can appear. CURSOR c1 (median IN NUMBER)
ISSELECT job, ename FROM emp WHERE sal > median;
43.What are the various types of RollBack Segments ?
ublic Available to all instancesPrivate Available to specific instance
44.Can you use %RowCount as a parameter to a cursor ?Yes
45.Is the query below allowed :Select sal, ename Into x From emp Where ename = 'KING'(Where x is a record

of Number(4) and Char(15))


Yes
Posted by Ravi Buddhaat 1:54 PM

2 comments:

MURLYB said...
May be I am not the right person to place this comment. For that excuse me, The questions and
answers are very useful. But I want to say that there is a small mistake in your first question
program. In your code you wrote that
"SELECT SAL IN TO SALARYFROM EMP WHERE ENAME='ANURAG' "
by seeing the about most of the people feel that the mistake is at SALARYFROM but the actual
mistake is at "IN TO".
Here INTO IS A CLAUSE if we give space between IN and TO the flavour will be missed.
More over this comment is not for you. because typos may occur at the time of typing.... THIS
COMMENT IS FOR THE BEGINNERS WHO ARE READING YOUR DATA.
February 6, 2015 at 6:41 AM

vergarasofia197@gmail.com said...
Tks very much for your post.
Avoid surprises interviews need preparation. Some questions come up time and time again
usually about you, your experience and the job itself. We've gathered together the most common
questions so you can get your preparation off to a flying start.

You might also like