300+ TOP ORACLE Interview Questions and Answers

ORACLE Interview Questions for freshers experienced :-

1. What is an Oracle table?
A table is basic unit of data storage in Oracle database. A table contains all the accessible information of a user in rows and columns.

2. Difference between varchar and varchar2 data types?
Varchar can store upto 2000 bytes and varchar2 can store upto 4000 bytes. Varchar will occupy space for NULL values and Varchar2 will not occupy any space. Both are differed with respect to space.

3. In which language Oracle has been developed?
Oracle has been developed using C Language.

4. What is the use of NVL function?
The NVL function is used to replace NULL values with another or given value. Example is –

NVL(Value, replace value)

5. Whether any commands are used for Months calculation? If so, What are they?
In Oracle, months_between function is used to find number of months between the given dates. Example is –

Months_between(Date 1, Date 2)

6. What are nested tables?
Nested table is a data type in Oracle which is used to support columns containing multi valued attributes. It also hold entire sub table.

7. What is COALESCE function?
COALESCE function is used to return the value which is set to be not null in the list. If all values in the list are null, then the coalesce function will return NULL.

Coalesce(value1, value2,value3,…)

8. What is BLOB datatype?
A BLOB data type is a varying length binary string which is used to store two gigabytes memory. Length should be specified in Bytes for BLOB.

9. How do we represent comments in Oracle?
Comments in Oracle can be represented in two ways –

Two dashes(–) before beginning of the line – Single statement

/*—— */ is used to represent it as comments for block of statement

10. What is DML?
Data Manipulation Language (DML) is used to access and manipulate data in the existing objects. DML statements are insert, select, update and delete and it won’t implicitly commit the current transaction.

ORACLE Interview Questions
ORACLE Interview Questions

11. What is the difference between TRANSLATE and REPLACE?
Translate is used for character by character substitution and Replace is used substitute a single character with a word.

12. How do we display rows from the table without duplicates?
Duplicate rows can be removed by using the keyword DISTINCT in the select statement.

13. What is the usage of Merge Statement?
Merge statement is used to select rows from one or more data source for updating and insertion into a table or a view. It is used to combine multiple operations.

14. What is NULL value in oracle?
NULL value represents missing or unknown data. This is used as a place holder or represented it in as default entry to indicate that there is no actual data present.

15. What is USING Clause and give example?
The USING clause is used to specify with the column to test for equality when two tables are joined.

[sql]Select * from employee join salary using employee ID[/sql]

Employee tables join with the Salary tables with the Employee ID.

16. What is key preserved table?
A table is set to be key preserved table if every key of the table can also be the key of the result of the join. It guarantees to return only one copy of each row from the base table.

17. What is WITH CHECK OPTION?
The WITH CHECK option clause specifies check level to be done in DML statements. It is used to prevent changes to a view that would produce results that are not included in the sub query.

18. What is the use of Aggregate functions in Oracle?
Aggregate function is a function where values of multiple rows or records are joined together to get a single value output.

Common aggregate functions are:

  • Average
  • Count
  • Sum

19. What do you mean by GROUP BY Clause?
A GROUP BY clause can be used in select statement where it will collect data across multiple records and group the results by one or more columns.

20. What is a sub query and what are the different types of subqueries?

Sub Query is also called as Nested Query or Inner Query which is used to get data from multiple tables. A sub query is added in the where clause of the main query.

There are two different types of subqueries:

Correlated sub query

  • A Correlated sub query cannot be as independent query but can reference column in a table listed in the from list of the outer query.

Non-Correlated subquery

  • This can be evaluated as if it were an independent query. Results of the sub query are submitted to the main query or parent query.

21. What is cross join?
Cross join is defined as the Cartesian product of records from the tables present in the join. Cross join will produce result which combines each row from the first table with the each row from the second table.

22. What are temporal data types in Oracle?
Oracle provides following temporal data types:

Date Data Type – Different formats of Dates

TimeStamp Data Type – Different formats of Time Stamp

Interval Data Type – Interval between dates and time

23. How do we create privileges in Oracle?
A privilege is nothing but right to execute an SQL query or to access another user object. Privilege can be given as system privilege or user privilege.

[sql]GRANT user1 TO user2 WITH MANAGER OPTION;[/sql]

24. What is VArray?
VArray is an oracle data type used to have columns containing multivalued attributes and it can hold bounded array of values.

25. How do we get field details of a table?
Describe <Table_Name> is used to get the field details of a specified table.

26. What is the difference between rename and alias?

Rename is a permanent name given to a table or a column whereas Alias is a temporary name given to a table or column. Rename is nothing but replacement of name and Alias is an alternate name of the table or column.

27. What is a View?
View is a logical table which based on one or more tables or views. The tables upon which the view is based are called Base Tables and it doesn’t contain data.

28. What is a cursor variable?
A cursor variable is associated with different statements which can hold different values at run time. A cursor variable is a kind of reference type.

29. What are cursor attributes?
Each cursor in Oracle has set of attributes which enables an application program to test the state of the cursor. The attributes can be used to check whether cursor is opened or closed, found or not found and also find row count.

30. What are SET operators?
SET operators are used with two or more queries and those operators are Union, Union All, Intersect and Minus.

31. How can we delete duplicate rows in a table?
Duplicate rows in the table can be deleted by using ROWID.

32. What are the attributes of Cursor?
Attributes of Cursor are

%FOUND

Returns NULL if cursor is open and fetch has not been executed

Returns TRUE if the fetch of cursor is executed successfully.

Returns False if no rows are returned.

%NOT FOUND

Returns NULL if cursor is open and fetch has not been executed

Returns False if fetch has been executed

Returns True if no row was returned

%ISOPEN

Returns true if the cursor is open

Returns false if the cursor is closed

%ROWCOUNT

Returns the number of rows fetched. It has to be iterated through entire cursor to give exact real count.

33. Can we store pictures in the database and if so, how it can be done?

Yes, we can store pictures in the database by Long Raw Data type. This datatype is used to store binary data for 2 gigabytes of length. But the table can have only on Long Raw data type.

34. What is an integrity constraint?
An integrity constraint is a declaration defined a business rule for a table column. Integrity constraints are used to ensure accuracy and consistency of data in a database. There are types – Domain Integrity, Referential Integrity and Domain Integrity.

35. What is an ALERT?
An alert is a window which appears in the center of the screen overlaying a portion of the current display.

36. What is hash cluster?
Hash Cluster is a technique used to store the table for faster retrieval. Apply hash value on the table to retrieve the rows from the table.

37. What are the various constraints used in Oracle?
Following are constraints used:

  • NULL – It is to indicate that particular column can contain NULL values
  • NOT NULL – It is to indicate that particular column cannot contain NULL values
  • CHECK – Validate that values in the given column to meet the specific criteria
  • DEFAULT – It is to indicate the value is assigned to default value

38. What is difference between SUBSTR and INSTR?
SUBSTR returns specific portion of a string and INSTR provides character position in which a pattern is found in a string.

SUBSTR returns string whereas INSTR returns numeric.

39. What is the parameter mode that can be passed to a procedure?
IN, OUT and INOUT are the modes of parameters that can be passed to a procedure.

40. What are the different Oracle Database objects?
There are different data objects in Oracle –

  • Tables – set of elements organized in vertical and horizontal
  • Views – Virtual table derived from one or more tables
  • Indexes – Performance tuning method for processing the records
  • Synonyms – Alias name for tables
  • Sequences – Multiple users generate unique numbers
  • Tablespaces – Logical storage unit in Oracle

41. What are the differences between LOV and List Item?
LOV is property whereas list items are considered as single item. List of items is set to be a collection of list of items. A list item can have only one column, LOV can have one or more columns.

42. What are privileges and Grants?
Privileges are the rights to execute SQL statements – means Right to connect and connect. Grants are given to the object so that objects can be accessed accordingly. Grants can be provided by the owner or creator of an object.

43. What is the difference between $ORACLE_BASE and $ORACLE_HOME?
Oracle base is the main or root directory of an oracle whereas ORACLE_HOME is located beneath base folder in which all oracle products reside.

44. What is the fastest query method to fetch data from the table?
Row can be fetched from table by using ROWID. Using ROW ID is the fastest query method to fetch data from the table.

45. What is the maximum number of triggers that can be applied to a single table?
12 is the maximum number of triggers that can be applied to a single table.

46. How to display row numbers with the records?
Display row numbers with the records numbers –

Select rownum, <fieldnames> from table;

This query will display row numbers and the field values from the given table.

47. How can we view last record added to a table?
Last record can be added to a table and this can be done by –

Select * from (select * from employees order by rownum desc) where rownum<2;

48. What is the data type of DUAL table?
The DUAL table is a one-column table present in oracle database. The table has a single VARCHAR2(1) column called DUMMY which has a value of ‘X’.

49. What is difference between Cartesian Join and Cross Join?

There are no differences between the join. Cartesian and Cross joins are same. Cross join gives cartesian product of two tables – Rows from first table is multiplied with another table which is called cartesian product.

Cross join without where clause gives Cartesian product.

50. How to display employee records who gets more salary than the average salary in the department?
This can be done by this query –

Select * from employee where salary>(select avg(salary) from dept, employee where dept.deptno = employee.deptno;

51. What database block size should I use? (for DBA)
Oracle recommends that your database block size match, or be multiples of your operating system block size. One can use smaller block sizes, but the performance cost is significant. Your choice should depend on the type of application you are running. If you have many small transactions as with OLTP, use a smaller block size. With fewer but larger transactions, as with a DSS application, use a larger block size. If you are using a volume manager, consider your “operating system block size” to be 8K. This is because volume manager products use 8K blocks (and this is not configurable).

52. What are the different approaches used by Optimizer in choosing an execution plan ?
Rule-based and Cost-based.

53. What does ROLLBACK do ?
ROLLBACK retracts any of the changes resulting from the SQL statements in the transaction.

54. How does one coalesce free space ? (for DBA)

  • SMON coalesces free space (extents) into larger, contiguous extents every 2 hours and even then, only for a short period of time.
  • SMON will not coalesce free space if a tablespace’s default storage parameter “pctincrease” is set to 0. With Oracle 7.3 one can manually coalesce a tablespace using the ALTER TABLESPACE … COALESCE; command, until then use:
  1. SQL> alter session set events ‘immediate trace name coalesce level n’;
  2. Where ‘n’ is the tablespace number you get from SELECT TS#, NAME FROM SYS.TS$;
  3. You can get status information about this process by selecting from the SYS.DBA_FREE_SPACE_COALESCED dictionary view.

55. What is COST-based approach to optimization ?
Considering available access paths and determining the most efficient execution plan based on statistics in the data dictionary for the tables accessed by the statement and their associated clusters and indexes.

56. What does COMMIT do ?
COMMIT makes permanent the changes resulting from all SQL statements in the transaction. The changes made by the SQL statements of a transaction become visible to other user sessions transactions that start only after transaction is committed.

57. How are extents allocated to a segment?
Oracle8 and above rounds off extents to a multiple of 5 blocks when more than 5 blocks are requested. If one requests 16K or 2 blocks (assuming a 8K block size), Oracle doesn’t round it up to 5 blocks, but it allocates 2 blocks or 16K as requested. If one asks for 8 blocks, Oracle will round it up to 10 blocks.

Space allocation also depends upon the size of contiguous free space available. If one asks for 8 blocks and Oracle finds a contiguous free space that is exactly 8 blocks, it would give it you. If it were 9 blocks, Oracle would also give it to you. Clearly Oracle doesn’t always round extents to a multiple of 5 blocks.

The exception to this rule is locally managed tablespaces. If a tablespace is created with local extent management and the extent size is 64K, then Oracle allocates 64K or 8 blocks assuming 8K-block size. Oracle doesn’t round it up to the multiple of 5 when a tablespace is locally managed.

58. Define Transaction ?
A Transaction is a logical unit of work that comprises one or more SQL statements executed by a single user.

59. What is Read-Only Transaction ?
A Read-Only transaction ensures that the results of each query executed in the transaction are consistant with respect to the same point in time.

60. What is a deadlock ? Explain .
Two processes wating to update the rows of a table which are locked by the other process then deadlock arises. In a database environment this will often happen because of not issuing proper row lock commands. Poor design of front-end application may cause this situation and the performance of server will reduce drastically.

These locks will be released automatically when a commit/rollback operation performed or any one of this processes being killed externally.

61. What is RAW datatype?
RAW datatype is used to store values in binary data format. The maximum size for a raw in a table in 32767 bytes.

62. What is a snapshot in Oracle database?
A snapshot is a replica of a target master table from a single point-in-time. In simple words you can say, snapshot is a copy of a table on a remote database.

ORACLE Questions and Answers Pdf Download

300+ [LATEST] Oracle Interview Questions and Answers

Q1. What Are The Two Parts Of A Procedure ?

Procedure Specification and Procedure Body.

Q2. What Are Schema Objects?

Schema objects are the logical structures that directly refer to the database’s data. Schema objects include tables, views, sequences, synonyms, indexes, clusters, database triggers, procedures, functions packages and database links.

Q3. What Is Rollback Segment ?

A Database contains one or more Rollback Segments to temporarily store “undo” information.

Q4. How Does Space Allocation Table Place Within A Block ?

  • Each block contains entries as follows
  • Fixed block header
  • Variable block header
  • Row Header,row date (multiple rows may exists)
  • PCTEREE (% of free space for row updation in future)

Q5. What Are The Various Types Of Queries ?

  • Normal Queries
  • Sub Queries
  • Co-related queries
  • Nested queries
  • Compound queries.

Q6. Is It Possible To Split The Print Reviewer Into More Than One Region?

Yes.

Q7. What Will Be Your Partitioning Strategy On Gl_balances? Your Views Please?

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.

Q8. What Are Mutating Triggers ?

A trigger giving a SELECT on the table on which the trigger is written.

Q9. Which Symbol Preceeds The Path To The Table In The Remote Database?

@.

Q10. What Is The Effect Of Synonym And Table Name Used In Same Select Statement ?

Valid.

Q11. What Is A Trace File And How Is It Created ?

Each server and background process can write an associated trace file. When an internal error is detected by a process or user process, it dumps information about the error to its trace. This can be used for tuning the database.

Q12. What Is The Use Of Indexes Option In Exp Command ?

A flag to indicate whether indexes on tables will be exported.

Q13. How Is Mapping Of Name Of Dll And Function Done?

The dll can be created using the Visual C++ / Visual Basic Tools and then the dll is put in the path that is defined the registry.

Q14. Can You Connect To Non – Oracle Datasource?

Yes.

Q15. What Is The Use Of Redo Log Information?

The information in a redo log file is used only to recover the database from a system or media failure prevents database data from being written to a database’s data files.

Q16. Explain About Stacked Canvas Views?

Stacked canvas view is displayed in a window on top of, or “stacked” on the content canvas view assigned to that same window. Stacked canvas views obscure some part of the underlying content canvas view, and or often shown and hidden programmatically.

Q17. Display The Records Between Two Range?

select rownum, empno, ename from emp where rowid in (select rowid from emp where rownum <=&upto minus select rowid from emp where rownum<&Start);

Q18. In Oa Framework Self-service Screen, You Wish To Disable A Tab. How Will You Do It?

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.

Q19. What Are The Different Type Of Segments ?

The different type of Segments are:

  • Data Segment,
  • Index Segment,
  • Rollback Segment and
  • Temporary Segment.

Q20. What Is Pl/sql?

PL/SQL is Oracle’s Procedural Language extension to SQL. The language includes object oriented programming techniques such as encapsulation, function overloading, information hiding (all but inheritance), and so, brings state-of-the-art programming to the Oracle database server and a variety of Oracle tools.

Q21. What Is The Difference Between Alias And Synonym ?

Alias is temporary and used with one query. Synonym is permanent and not used as alias.

Q22. Any Work Done In Oracle Workflow Builder. Did You Customize Or Build A New Workflow?

Yes, I customized the Work Flow For Credit Memo Request approval in AR through Workflow Builder.

Q23. How Many Types Of Sql Statements Are There In Oracle?

There are basically 6 types of sql statments.They are

  • Data Definition Language(DDL) :: The DDL statements define and maintain objects and drop objects.
  • Data Manipulation Language(DML) :: The DML statements manipulate database data.
  • Traction Control Statements :: Manage change by DML
  • Session Control :: Used to control the properties of current session enabling and disabling roles and changing .e.g. :: Alter Statements, Set Role
  • System Control Statements :: Change Properties of Oracle Instance .e.g.:: Alter System
  • Embedded Sql :: Incorporate DDL, DML and T.C.S in Programming Language.e.g:: Using the Sql Statements in languages such as ‘C’, Open, Fetch, execute and close

Q24. What Is The Difference Between Name_in And Copy ?

Copy is package procedure and writes values into a field. Name in is a package function and returns the contents of the variable to which you apply.

Q25. What Are The Two Ways By Which Data Can Be Generated For A Parameters List Of Values?

  1. Using static values.
  2. Writing select statement.

Q26. What Is Sql*loader And What Is It Used For?

SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. Its syntax is similar to that of the DB2 Load utility, but comes with more options. SQL*Loader supports various load formats, selective loading, and multi-table loads.

Q27. What Are The Use Of Roles ?

The use of Roles are:

  • REDUCED GRANTING OF PRIVILEGES – Rather than explicitly granting the same set of privileges to many users a database administrator can grant the privileges for a group of related users granted to a role and then grant only the role to each member of the group.
  • DYNAMIC PRIVILEGE MANAGEMENT – When the privileges of a group must change, only the privileges of the role need to be modified. The security domains of all users granted the group’s role automatically reflect the changes made to the role.
  • SELECTIVE AVAILABILITY OF PRIVILEGES – The roles granted to a user can be selectively enable (available for use) or disabled (not available for use). This allows specific control of a user’s privileges in any given situation.
  • APPLICATION AWARENESS – A database application can be designed to automatically enable and disable selective roles when a user attempts to use the application.

Q28. What Is The Best Way To Add Debugging To The Code In Apps?

Use fnd_log.string , i.e. FND Logging. Behind the scenes Oracles FND Logging uses autonomous traction 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.

 

Q29. How Does One Create A Rman Recovery Catalog?

Start by creating a database schema (usually called rman). Assign an appropriate tablespace to it and grant it the recovery_catalog_owner role. Look at this example: 

  sqlplus sys
SQL>create user rman identified by rman;
SQL> alter user rman default tablespace tools temporary tablespace temp;
SQL> alter user rman quota unlimited on tools;
SQL> grant connect, resource, recovery_catalog_owner to rman;
SQL> exit;

Next, log in to rman and create the catalog schema. Prior to Oracle 8i this was done by running the catrman.sql script. rman catalog rman/rman

  RMAN>create catalog tablespace tools;
RMAN> exit;

You can now continue by registering your databases in the catalog. Look at this example: 
rman catalog rman/rman target backdba/backdba

  RMAN> register database;

Q30. What Is The Difference Between An On-validate-field Trigger And A Trigger ?

On-validate-field trigger fires, when the field Validation status New or changed. Post-field-trigger whenever the control leaving form the field, it will fire.

Q31. What Are Two Parts Of Package ?

The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY. Package Specification contains declarations that are global to the packages and local to the schema. Package Body contains actual procedures and local declaration of the procedures and cursor declarations.

Q32. What Is A Trigger ?

A piece of logic that is executed at or triggered by a SQL *forms event.

Q33. What Does Invoke Built-in Do?

This procedure invokes a method.

Syntax:

  PROCEDURE OLE2.INVOKE  (object obj_type,  method VARCHAR2,  list list_type := 0);  

Parameters:

  • object Is an OLE2 Automation Object.
  • method Is a method (procedure) of the OLE2 object.
  • list Is the name of an argument list assigned to the OLE2.CREATE_ARGLIST function.

Q34. Were You Involved In Any Data Conversion, Which One?

We have done data conversion for1.Suppliers2.AP Invoices3.Customers@AR Invoices.

Q35. What Is Oracle Label Security?

Oracle Label Security (formerly called Trusted Oracle MLS RDBMS) uses the VPD (Virtual Private Database) feature of Oracle8i to implement row level security. Access to rows are restricted according to a user’s security sensitivity tag or label. Oracle Label Security is configured, controlled and managed from the Policy Manager, an Enterprise Manager-based GUI utility.

Q36. In A Distributed Database System Can We Execute Two Queries Simultaneously? Justify?

Yes Distributed database system based on 2 phase commit, one query is independent of 2nd query so of course we can run.

Q37. Can You Pass Values To-and-fro From Foreign Function? How?

Yes . You obtain a return value from a foreign function by assigning the return value to an Oracle Forms variable or item. Make sure that the Oracle Forms variable or item is the same data type as the return value from the foreign function.

After assigning an Oracle Forms variable or item value to a PL/SQL variable, pass the PL/SQL variable as a parameter value in the PL/SQL interface of the foreign function. The PL/SQL variable that is passed as a parameter must be a valid PL/SQL data type; it must also be the appropriate parameter type as defined in the PL/SQL interface.

Q38. What Is The Basic Structure Of Pl/sql ?

PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.

Q39. What Is An Integrity Constraint?

Integrity constraint is a rule that restricts values to a column in a table.

Q40. What Is Oem (oracle Enterprise Manager)?

OEM is a set of systems management tools provided by Oracle Corporation for managing the Oracle environment. It provides tools to monitor the Oracle environment and automate tasks (both one-time and repetitive in nature) to take database administration a step closer to “Lights Out” management.

Q41. What Is An Oracle Index?

An index is an optional structure associated with a table to have direct access to rows, which can be created to increase the performance of data retrieval. Index can be created on one or more columns of a table.

Q42. What Is The Sub-query?

Sub-query is a query whose return values are used in filtering conditions of the main query.

Q43. Explain About Horizontal, Vertical Tool Bar Canvas Views?

Tool bar canvas views are used to create tool bars for individual windows. Horizontal tool bars are display at the top of a window, just under its menu bar. Vertical Tool bars are displayed along the left side of a window.

Q44. What Are The Various Ways To Kick-off A Workflow?

You can eiter use wf_engine. start_process or you can attach a runnable process such ghat it subscribes to a workflow event.

Q45. Does Oracle Have A Test Environment On Exchange?

http://testexchange.oracle.com.

Q46. How To Retrieve The Count Of Updated Rows?

After running an UPDATE statement, the database server returns a count of updated rows. You can retrieve this count from a special predefined variable called SQL%ROWCOUT, as shown in the following tutorial:

  CREATE TABLE emp_temp AS SELECT * FROM employees;  BEGIN  UPDATE emp_temp SET salary = salary * 1.05  WHERE salary < 5000;  DBMS_OUTPUT.PUT_LINE('# of rows updated: ' ||  SQL%ROWCOUNT);  END;  /  # of rows updated: 49  

Q47. What Are The Built-ins Used For Finding Object Id Functions?

  • Find_group(function)
  • Find_column(function)

Q48. How Can We Integrate Ar Or Ap To Gl?

we integrate AR or AP to GL through Set of Books.

Q49. Explain The Relationship Among Database, Tablespace And Data File?

Each databases logically divided into one or more tablespaces one or more data files are explicitly created for each tablespace.

Q50. Can You Pass Data Parameters To Forms?

No.