Oracle interview questions and answers

In this post we will discuss some basic Oracle Interview questions and answers. Answers given are very precise. Please help me to improve the answer if you think so. I will be regularly updating this post.

1. What is the difference between Procedure and Function ?


a) Function  must return a value and procedure need not.

b) Function can be used in SQL with some restrictions. Procedure cannot be called directly from SQL.

2. What is the difference between Anonymous blocks and sub programs ?

Ans :-

a)  Anonymous blocks are unnamed blocks which are not stored anywhere while sub programs are compiled and stored in database.

b) Anonymous blocks compile at run time.

3. What is the difference between DELETE and TRUNCATE ?


a) DELETE is a DML command and TRUNCATE is a DDL command.

b) TRUNCATE re-set the memory blocks after execution and much faster than DELETE in most of the circumstances.

4. What is Implicit Cursor and Explicit Cursor ?

a) Implicit Cursor is defined and controlled by Oracle Internally.

Example :-

v_ename varchar2(50);
select ename into v_ename from emp where empno = 10;

select query used in above PL/SQL block is an implicit cursor

b) Explicit Cursor is defined and controlled programatically.

Example :-

v_ename varchar2(50);
Cursor Cur_ename is select ename into v_ename from emp where empno = 10;
Open Cur_ename;
Fetch Cur_ename into v_ename;
Close Cur_ename;

5. Difference between DECODE and CASE 

Ans :- Click here

6. How to find Nth highest salary ?

Ans :- Click here

7. Difference between UNION and UNION ALL clause

Ans :- Click here

8. What is Autonomous Transaction ?

Ans :- Click here

9. Difference between REPLACE and TRANSLATE functions

Ans:- Click here

10.  What is LEAD and LAG function used for ?

Ans:- Click here

11.  Explain function or procedure overloading

Ans:- Click here

12.  What is MERGE used for ?

Ans:- Click here

13.  What is GREATEST and LEAST function used for ? 

Ans:- Click here

14. Where we use SOUNDEX function ?

Ans:- Click here

15.  What is COALESCE function ?

Ans:- Click here

16. Difference between TRUNC and ROUND function

Ans:- Click here

17. How to convert Julian Date to date ?

Ans :- Using ‘JSP’ format string

SQL > select to_char(to_date(2456317,’JSP’),’dd-Mon-yyyy’) as day  from dual;


18. How to convert date to Julian Date format ?

Ans :- Using ‘J’ format string

SQL > select to_char(to_date(’24-Jan-2013′,’dd-mon-yyyy’),’J’) as julian from dual;


19. What is the difference between PRIMARY KEY and UNIQUE KEY constraints ?

1. UNIQUE KEY columns can have null values but PRIMARY KEY column cannot accept null values.

2. A table can have only one PRIMARY KEY column but many UNIQUE KEY columns allowed.

( I can spot only two. Any more difference ? )

20. What is PRAGMA ?

PRAGMA is Oracle keyword to telling the compiler to do some special work.

Examples :-



21. What is Constraint ? How many constraints are available ?

Ans :- Explained in another post

22. What is Cartesian Product ?

If two or more tables are joining without join condition will result into Cartesian products.

If table A has 2 rows and table B has 4 rows then Cartesian product between A and B will return 8 rows ( 2 multiply by 4 )

You want to improve the answer ? Please add your comment or send email.

See Also

Install Oracle in Ubuntu 12.04
Latest version of Oracle database – Oracle 12c 
Oracle 12C New Features
Notepad++ – Tips and Tricks
Remote desktop in ubuntu 12.04
Install Skype in Ubuntu 12.04
Install Microsoft fonts in Ubuntu 12.04
Latest version of Oracle database – Oracle 12c


Author: sqlandplsql

To learn more about the Oracle, SQL, PL SQL, Performance Tuning, Database Modeling, Ubuntu, MySQL etc .Suggestions, comments, feedbacks and referrals are highly appreciated.

27 thoughts on “Oracle interview questions and answers”

    1. Primary key wont allow null values
      primary key wont allow duplicate values
      unique key will allow null values
      unique key wont allow duplicate values

  1. Actually the major difference of Primary key and Unique key is when we create primary key automatically index will be created but for unique index wont created.
    I faced that question in Interviews.

  2. Thank you, I’ve recently been searching for info approximately this topic for a while
    and yours is the greatest I have came upon so far. But, what concerning the
    conclusion? Are you certain concerning the source?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s