List of Top Oracle Interview Questions
List of Top Oracle Interview Questions
For Example,
Answer: Both VARCHAR & VARCHAR2 are Oracle data types that are used to store
character strings of variable length. Their differences are:
Answer: Both the commands are used to remove data from the database.
The difference between RAW & VARCHAR2 datatype is that PL/SQL does not recognize
this data type and hence, cannot do any conversions when RAW data is transferred to
different systems. This data type can only be queried or inserted in a table.
Syntax: RAW (precision)
Answer: Joins are used to extract data from multiple tables using some common
columns or conditions.
INNER JOIN
OUTER JOIN
CROSS JOINS or CARTESIAN PRODUCT
EQUI JOIN
ANTI JOIN
SEMI JOIN
Answer:
SUBSTR function returns the sub-part identified by numeric values from the
provided string.
For Example, [SELECT SUBSTR (‘India is my country’, 1, 4) from
dual] will return “Indi”.
INSTR will return the position number of the sub-string within the string.
For Example, [SELECT INSTR (‘India is my country’, ‘a’) from dual]
will return 5.
Q #8) How can we find out the duplicate values in an Oracle table?
Answer: We can use the below example query to fetch the duplicate records.
We can add ON DELETE CASCADE option on an existing table using the below set of
commands.
Syntax:
Answer: NVL is a function that helps the user to substitute value if null is encountered for
an expression.
Q #11) What is the difference between a Primary Key & a Unique Key?
Answer: Primary Key is used to identify each table row uniquely, while a Unique Key
prevents duplicate values in a table column.
The primary key can be only one on the table while unique keys can be
multiple.
The primary key cannot hold null value at all while the unique key allows
multiple null values.
The primary key is a clustered index while a unique key is a non-clustered
index.
For Example:
Answer: We can find the current date & time using SYSDATE command in Oracle.
Syntax:
Answer: COALESCE function is used to return the first non-null expression from the list
of arguments provided in the expression. There must be a minimum of two arguments in
an expression.
Syntax:
Q #15) How will you write a query to get 5th RANK students from the table
STUDENT_REPORT?
Answer: GROUP BY clause is used to identify and group the data by one or more
columns in the query results. This clause is often used with aggregate functions like
COUNT, MAX, MIN, SUM, AVG, etc.
Syntax:
Q #17) What is the quickest way to fetch the data from a table?
Answer: The quickest way to fetch the data would be to use ROWID in the SQL query.
For Example:
DECODE Function
Select ORDERNUM,
DECODE (STATUS,'O', ‘ORDERED’,'P', ‘PACKED,’S’,’SHIPPED’,’A’,’ARRIVED’)
FROM ORDERS;
CASE Function
Select ORDERNUM
, CASE (WHEN STATUS ='O' then ‘ORDERED’
WHEN STATUS ='P' then PACKED
WHEN STATUS ='S' then ’SHIPPED’
ELSE ’ARRIVED’) END
FROM ORDERS;
Both the commands will display order numbers with their respective status as,
If,
Status O= Ordered
Status P= Packed
Status S= Shipped
Status A= Arrived
Various integrity constraints are available which include Primary Key, Foreign Key,
UNIQUE KEY, NOT NULL & CHECK.
Q #20) What do you mean by MERGE in Oracle and how can we merge two tables?
Answer: The MERGE statement is used to merge the data from two tables. It selects the
data from the source table and inserts/updates it in the other table based on the condition
provided in the MERGE query.
Syntax:
MERGE INTO TARGET_TABLE_1
USING SOURCE_TABLE_1
ON SEARCH_CONDITION
WHEN MATCHED THEN
INSERT (COL_1, COL_2…)
VALUES (VAL_1, VAL_2…)
WHERE <CONDITION>
WHEN NOT MATCHED THEN
UPDATE SET COL_1=VAL_1, COL_2=VAL_2…
WHEN <CONDITION>
AVG
MIN
MAX
COUNT
SUM
STDEV
Q #22) What are the set operators UNION, UNION ALL, MINUS & INTERSECT meant
to do?
Answer: The set operator facilitates the user to fetch the data from two or more than two
tables at once if the columns and relative data types are the same in the source tables.
UNION operator returns all the rows from both the tables except the duplicate
rows.
UNION ALL returns all the rows from both the tables along with the duplicate
rows.
MINUS returns rows from the first table, which does not exist in the second
table.
INTERSECT returns only the common rows in both the tables.
Q #23) Can we convert a date to char in Oracle and if so, what would be the
syntax?
Syntax:
SELECT to_char (to_date ('30-01-2018', 'DD-MM-YYYY'), 'YYYY-MM-DD') FRO
M dual;
Q #24) What do you mean by a database transaction & what all TCL statements are
available in Oracle?
Answer: Transaction occurs when a set of SQL statements are executed in one go. To
control the execution of these statements, Oracle has introduced TCL i.e. Transaction
Control Statements that use a set of statements.
Q #25) What do you understand by a database object? Can you list a few of them?
Answer: Object used to store the data or references of the data in a database is known
as a database object. The database consists of various types of DB objects such as
tables, views, indexes, constraints, stored procedures, triggers, etc.
Q #26) What is a nested table and how is it different from a normal table?
Answer: A nested table is a database collection object, which can be stored as a column
in a table. While creating a normal table, an entire nested table can be referenced in a
single column. Nested tables have only one column with no restriction of rows.
For Example:
CREATE TABLE EMP (
EMP_ID NUMBER,
EMP_NAME TYPE_NAME)
Here, we are creating a normal table as EMP and referring a nested table TYPE_NAME
as a column.
Answer: BLOB stands for Binary Large Object, which is a data type that is generally
used to hold images, audio & video files or some binary executables. This datatype has
the capacity of holding data up to 4 GB.
Q #28) What do you understand by database schema and what does it hold?
A table can hold data but not SQL query results whereas View can save the
query results, which can be used in another SQL query as a whole.
The table can be updated or deleted while Views cannot be done so.
Answer: Deadlock is a situation when two or more users are simultaneously waiting for
the data, which is locked by each other. Hence it results in all blocked user sessions.
Answer: An index is a schema object, which is created to search the data efficiently
within the table. Indexes are usually created on certain columns of the table, which are
accessed the most. Indexes can be clustered or non-clustered.
Syntax:
(i) %FOUND:
Returns INVALID_CURSOR if the cursor has been declared but closed.
Returns NULL if fetch has not happened but the cursor is open only.
Returns TRUE, if the rows are fetched successfully and FALSE if no rows are
returned.
Answer: %ROWTYPE & %TYPE are the attributes in PL/SQL that can inherit the
datatypes of a table defined in a database. The purpose of using these attributes is to
provide data independence and integrity.
If any of the datatypes or precision gets changed in the database, PL/SQL code gets
updated automatically with the changed data type.
%TYPE is used for declaring a variable that needs to have the same data type as of a
table column.
While %ROWTYPE will be used to define a complete row of records having a structure
similar to the structure of a table.
Q #36) Why do we create Stored Procedures & Functions in PL/SQL and how are
they different?
Answer: A stored procedure is a set of SQL statements that are written to perform a
specific task. These statements can be saved as a group in the database with an
assigned name and can be shared with different programs if permissions are there to
access the same.
Functions are again subprograms that are written to perform specific tasks but there are
differences between both of them.
Stored Procedures may or may not return a value and can Function will always
return multiple values as well. single value.
Stored Procedures Functions
Stored Procedures can include DML statements like insert, We cannot use DML sta
update & delete. function.
Stored Procedures support exception handling using Try/Catch Functions does not su
block. Try/Catch block.
Q #37) What are the parameters that we can pass through a stored procedure?
Answer: We can pass IN, OUT & INOUT parameters through a stored procedure and
they should be defined while declaring the procedure itself.
Answer: A trigger is a stored program which is written in such a way that it gets executed
automatically when some event occurs. This event can be any DML or a DDL operation.
Row Level
Statement Level
Q #39) How will you distinguish a global variable with a local variable in PL/SQL?
Answer: Global variable is the one, which is defined at the beginning of the program and
survives until the end. It can be accessed by any methods or procedures within the
program, while the access to the local variable is limited to the procedure or method
where it is declared.
Answer: A package is a group of related database objects like stored procs, functions,
types, triggers, cursors, etc. that are stored in the Oracle database. It is a kind of library
of related objects which can be accessed by multiple applications if permitted.
Q #2) How is the Clustered Index different from the Non-Clustered Index?
Answer: An index is a schema object, which can search the data efficiently within
the table.
Data files, which hold all the DB objects like tables, views, indexes, etc.
Redo Log files, which maintains the records of database changes as a result
of user transactions.
Control files, which maintain the database status and physical structure.
The logical structure includes:
Q #7) What do you mean by SGA and how is it different from PGA?
Answer: SGA means System Global Area is the memory area that is defined by
Oracle during instance startup. This area can be shared by the system-level
processes and hence it is known as the Shared Global Area as well.
Q #8) What is a password file in a database and why is it required when a user
can be authenticated using data dictionary tables?
If the database is in shutdown mode, then these tables cannot be accessed and
hence password file will be used by the database administrators to log in and open
the database.
Q #9) What are the different types of backups that are available in Oracle?
Answer: On a higher level, there are 2 types of backup that are available in Oracle
which are physical & logical.
During physical backup, copies of physical database files (like data files, control files,
redo logs & other executables) are created and saved for the future. This can be
achieved using either operating system utilities or RMAN.
In contrast, logical backup allows taking a backup of the database objects like tables,
views, indexes, stored procedures, etc. individually through Export/Import utility
provided by Oracle.
Q #10) What do we mean by hot backup & cold backup and how are they
different?
Answer: Hot backup is the process of taking database backup while the database is
in running mode. Hence, it is also known as Online Backup. While cold backup can
be taken only when the database is in shut down mode and hence it is known as
Offline Backup as well.
There are few websites like banking & trading ones, which are 24 hours operational
and hence, cannot support bringing the database down. Hence, DBAs need to take
the backup in online mode only.
Answer: During the restoration process, backup files are copied from the hard disk,
media or tapes to the restoration location and later make the database operational.
Recovery has an additional step of updating these data files by applying redo logs so
as to recover the changes which are not backed up.
Hence, the mirroring of these files is done to protect them. Redo Log file mirroring
allows redo logs to be copied to different disks simultaneously. And this can be
achieved using Data Guard and other utilities.
Answer: Incremental backup is known for keeping back up of only the changed data
files since the last backup, which might be full or incremental. For Example, An
incremental/full backup is done at 10 AM on Friday and the next backup is done at 10
AM Saturday. The second incremental backup will only have the transactions
occurred after Friday at 10 AM.
While Differential backup backs up the files that changed during the last full backup.
If you take a full back up on Friday at 10 AM and then differential backup on Saturday
at 10 AM, it will take the backup of the files changed since Friday, 10 AM. Further, if
the differential backup is taken on Sunday at 10 AM, it will take the backup of the files
changed since Friday, 10 AM.
Q #15) How is RMAN better than the user-managed backup recovery process?
RMAN backup time will be less when compared to user-managed backups as RMAN
maintains all the metadata in the Central Repository and can quickly retrieve the
same.
RMAN does incremental backup rather than taking full file backups which are done
by user-managed backups, which again saves time.
RMAN creates backup and recovery scripts that can be re-used and scheduled and
does not need manual intervention.
RMAN can detect corrupted data blocks automatically during the backup process and
recover them, whereas it doesn’t happen in user-managed backups.
restorecontrolfile;
Q #18) What is the difference between media recovery & crash recovery?
Answer: Media recovery is the process of recovering the database from the backup
whenever a disk failure is there. Physical files like data files, control files or server
parameter files get recovered during media recovery. However, crash recovery will
be performed whenever a database instance failure occurs.
Q #19) What is RAC and what are the various benefits of using RAC
architecture?
While grid, which may or may not consist of multiple clusters, possesses a wider
framework that enables sharing of storage systems, data resources and remaining
others across different geographical locations.
A cluster will have single ownership but the grid can have multiple ownership based
on the number of the cluster it holds.
Q #22) How can a single instance environment be converted into the RAC
environment and how will they be different?
Answer: Single instance can be converted into RAC using one of the below
methods:
Enterprise Manager
DBCA i.e. Database Configuration Assistant
RCONFIG Utility
Single Instance environment Vs RAC Environment
Single Instance
Parameters RAC Environment
Environment
Access to Only one instance will Data files and Control Files are sh
physical files access data files all instances.
and control files.
Answer: We can use the below data dictionary tables to monitor the space
allocations:;
DBA_FREE_SPACE
DBA_SEGMENTS
DBA_DATA_FILES
Q #24) What do you understand by “Performance Tuning of DB” & what are the
different areas where we can perform tuning?
Database design.
Memory allocation.
Disk I/Os.
Database contention.
OS level (CPU).
Q #25) What are the different tools that are provided by Oracle to assist
performance monitoring?
Answer: An explain plan is a statement that displays the execution plan selected by
the Oracle optimizer for SELECT, INSERT, UPDATE & DELETE statements. By
looking at this plan, one can figure out Oracle selection of the right indexes, proper
joins & sorts operations, etc.
Answer: TKPROF is a tuning utility provided by Oracle which can convert SQL trace
files into a readable format.
Once trace file is generated using SQL Trace Utility, the TKPROF tool can be run
against trace file and output can be read. It can also generate the execution plan for
SQL statements. The executable for TKPROF is located in the ORACLE HOME/bin
directory.
Answer: Enlisted are a few of the best practices for writing SQL queries.
Answer: When a row is too large that it cannot fit in a block, then it will end up using
consequent blocks which lead to the concept of Row Chaining. It can be avoided by
updating the storage parameters to an appropriate value.
Answer: It is a process of dividing a table into smaller chunks so as to make the data
retrieval easy and quick. Each piece will be known as a partition and can be
accessed separately. Apart from tables, indexes can also be partitioned.
Q #35) How can we identify the resources for which the sessions are waiting?
Answer: Oracle Forms are the user interfaces that are developed to present the data
to the user. This data can be presented once retrieved from the Oracle database. If
required, forms can be integrated with web services or Java to follow SOA
architecture. Forms are created at source as .fmb files and later compiled into .fmx
(executable file).
Client Level
Server Level
Database Level
At the client level, HTTP requests will be sent by a client to the system. This request
will be received by the Forms Listener Servlet at the server and it will initiate Forms
Runtime process. This process will send the request to the database to retrieve the
information and send it back to the client.
This completes the workflow of user interaction through Oracle Forms Services.
Answer: Yes, we can invoke one form from another with the help of the below
built-in functions:
OPEN_FORM: It opens up the requested form along with the current form
and the user can navigate to both the forms in the same session.
NEW_FORM: It will also open up a new form but after exiting from the current
form.
CALL_FORM: It will open the requested form by keeping the parent form
active but hidden. Once exited from the requested form, control goes back to
the parent form.
Q #4) What do you understand by LOV and how can it be used?
There is a related property known as ‘LOV for Validation’ which is used to validate
contents of LOV. If this property is set to true, the current value of text item is
compared with the values displayed in the first column of LOV.
If any of the LOV values match the text item, then validation succeeds and LOV will
not be displayed. If the value does not match, LOV will be displayed and a search will
happen based on the text item.
Answer: Canvas is a layer within a window where the visual objects like interface
items or graphics can be placed.
Answer: Oracle Forms follow the below hierarchy for trigger execution:
Pre-form
Pre-block
Pre-record
Pre-text item
When-new-form-instance
When-new-block-instance
When-new-record-instance
When-new-item-instance
Post-text_item
Post-Record
Post-Block
Post-Form
Q #7) Explain the Master-Detail relationship with some examples.
For Example, we can have one master named COMPANY with different details as
DEPARTMENTS (HR, FINANCE, OPERATIONS, ADMIN, etc.).
This relationship can be implemented with the help of two data blocks where the first
data block represents the master table while the other represents a detailed table.
Q #8) Name the different triggers associated with Oracle Forms having a
master-detail relationship.
ON-CHECK-DELETE-MASTER
ON-CLEAR-DETAILS
ON-POPULATE-DETAILS
Q #9) What are the various configuration files that are used by Oracle Forms?
Answer: The configuration files include:
default.env
formsweb.cfg
ftrace.cfg
base.htm,basejini.htm & basejpi.htm
Using the above config files, a user can specify different parameters for the forms as
per the requirement.
Answer: A record group is a framework of rows and columns within the Oracle
Forms similar to a table in the Oracle database.
The static record group is again not associated with any query and can be created or
updated during the design phase only.
Tabular
Master-Detail Reports
Form Reports
Form Letter Reports
Mailing Labels Reports
Matrix Reports
Q #12) What is an implicit anchor and how is it a different form explicit anchor
in a report builder?
Q #13) Name different triggers supported by Oracle Reports and their firing
order.
Answer: Bind parameters are the variables, which can replace a single value in
SQL/PLSQL such as number, character, string or date.
Answer: User exit is a program that is written to perform some relevant action. They
can be called from report triggers and once executed, it gives back the control to
Report Builder.
FND SRWINIT
FND SRWEXIT
FND FORMAT_CURRENCY
FND FLEXSQL
FND FLEXIDVAL
Q #17) How can we generate report output in Excel format?
Answer: To get report data in an Excel format, we can use:
SPOOL Command
Text_IO Package
UTL Package
Q #18) What is the difference between flex mode and confined mode?
Answer: Confined mode, if set restricts the child object within enclosing parent
objects. If not set on, the child objects can move out of parent objects.
During flex mode, parent objects will adjust its border if the child object expands or
moves. If not set, parent borders stay fixed when the child objects move.
Q #19) What is a matrix report and how many minimum groups are required to
prepare the same?
Answer: A matrix is a kind of report that looks like an information grid with one row of
labels and one column of columns. At least 4 groups are required in the data model
to prepare a matrix report. One should be a cross-product group, one cell group & at
least two groups should be within a cross-product group.
Ans: Oracle SOA Suite belongs to the Oracle Fusion Middleware group of software
products.
This tool is based on SOA architecture and helps in creating, managing & integrating
services with the application components so as to deliver SOA composite application
as one unit. This suite consists of five components.
BPEL Process
Oracle Mediator
Human Task Flow
Decision Services
Binding components include:
Services
References
Q #3 ) Can you explain the difference between architecture followed in 10g &
11g?
Answer: Given below are the differences between 10g and 11g:
JDeveloper
EMC(Enterprise Manager Console)
WebLogic Scripting.
Q #6) What is SCA and how is it useful?
OSB facilitates the same and resolves the issues between service clients and
business systems. SOA uses web services as building blocks to accomplish
enterprise integration and component re-usage through the loose coupling.
In Orchestration, a central process which can be a Web Service itself controls the
other web services involved in the integration of systems. This central coordinator will
coordinate the execution of various operations of web services involved in the
operation and completes the integration.
Clients
Application servers
Database servers
Clients will initiate the request for an operation to be executed by the database. The
application server will act as an intermediate layer by sending the client request to
the database and providing the requested data to the client.
Answer: No, we cannot create tables in APPS schema and this schema will only
have synonyms.
Answer: As the name itself suggests, the value set is a predefined list of values used
by Oracle for validation. It restricts the end-user to enter junk data by providing an
option to select a value from the predefined set of values.
Oracle supports eight types of value set validations. These are:
Answer: SQL * Loader is a utility that is used to import the data in bulk from external
files.
Answer: An executable file that can execute simultaneously with the other programs
and utilize the hardware capacity to the fullest is called the concurrent program.
Generally, these types of programs would be long-running and data-intensive. They
can be grouped with reports to form a request group.
This directory contains the files along with the relative directories:
Technology files
Product files
Oracle e-business suite environment files
Q #20) What do you understand by a set of books?