ORACLE PL/SQL Interview Questions You'll Most Likely Be Asked
ORACLE PL/SQL Interview Questions You'll Most Likely Be Asked
Questions
Review these typical interview questions and think about how you would
answer them. Read the answers listed; you will find best possible answers
along with strategies and suggestions.
This page is intentionally left blank
Chapter 1
General-Theory
conditional operator.
b) Case can work with searchable subqueries and predicates,
while decode works only scalar values.
c) A Case statement can be effectively substituted as If-then-
else statement as well as a parameter to any procedure
call, but Decode can only be used inside the function.
d) Case and Decode handles Null values differently
e) Case is ANSI compatible while Decode is not.
f) Case cannot handle data type inconsistency.
g) Decode statements are easily readable as compared to
Case.
6: What is a MERGE?
Answer:
The Merge statement is used to insert or update a data at certain
situations. Merge statements help to reduce the time taken to scan
the table, as well as in parallel, do the operation. The Merge
statement can do insert, update, delete simultaneously with the
single statement. As per the usage, the merge statements can be
used like merge into, merge update etc.
7: What is SPOOL?
Answer:
The spool command is used to direct the output of any kind of
query to the server-side file.
Syntax: SPOOL [file_name [. ext] [CREATE] | REPLACE] |
APPEND]] | OFF | OUT]
Example: SQL> spool /tmp/newfile.lst.
The spool command is usually interacting with the base layer. The
create helps to create a new file, replace helps to replace an
existing file with another, and append lets to add details into the
file or modify.
11: What are the main differences between SQL*Plus and SQL?
Answer:
SQL Plus is an interface used by Oracle where the SQL or PL/SQL
commands are executed. You can type the SQL and PL/SQL
commands on the SQL Plus command line which are executed by
Oracle Database. SQL is Structured Query Language which is
used to create, edit, delete and view the relational database tables
and schema. Simply put, SQL Plus is the GUI or environment
where the SQL commands are executed to manipulate or fetch
data from the relational database. SQL Plus is native to Oracle,
while SQL can be used by many relational databases.
of duplicate data which can make the data inconsistent and waste
a lot of precious data storage space. Normalization is the method
that ensures minimal or no data redundancy. A relational
database organizes the tables with minimal data redundancy
through the process of normalization. When the relations and data
depen
redundancy. This not only helps save the data storage space but
also makes data more consistent. If you have customer name and
18: What are the main differences between DBMS and RDBMS?
Answer:
Even though the term database is commonly used for DBMS and
RDBMS, they both differ considerably. In many ways, the RDBMS
is much superior to a simple DBMS model of data storage. Here
are some major differences between a DBMS and RDBMS:
a) The DBMS model stores data as a file whereas in an
RDBMS, data is stored in tabular or structured form.
b)
set between tables. It is done programmatically. In
RDBMS, table relations are set using the Primary Key
Foreign Key values. The keys exist in the database and can
be managed.
c)
the RDBMS strictly follows normalization rules.
d) DBMS is good to handle only small volumes of data while
RDBMS is meant to handle huge volumes of data.
e) DBMS does not handle data security while RDBMS insists
on data security and integrity.
f) DBMS supports only a single user while RDBMS can
handle multiple users.
Two more characteristics that are exclusive to RDBMS are that it
supports the client-server architecture and distributed database.
22: A table has the following data: [[5, Null, 10]].What will the
average function return?
Answer:
The average function typically returns the average of the values
provided as the arguments or parameters. But in Oracle, we can
use the function with tables provided it does not involve another
aggregate function or a subquery. In the given query, there are
three values out of which one is Null. The aggregate will skip the
Null value and consider the rest two only. So the result will be 7
which is the integer value of average of 5 and 10. If you want a
precise answer, you can cast the result into a double to get the
result 7.5.
implies that both the queries in the UNION should have the same
datatype. Here the first query results in an integer 1 and the
the current table data is only fetched which means that the view
results will change along with the change in the values of the table
corresponding to the view. If we create a view to store the results
of all employees belonging to a department, every time we query
the view, all records of employees belonging to the particular
department will be fetched which will also include the records
updated after the view was created.