Top Oracle Interview Questions: Oracle Basic, SQL, PL/SQL Questions

Q #1) What is Oracle and what are its different editions?
Ans: Oracle is one of the popular database provided by Oracle Corporation, which works on relational management concepts and hence it is referred as Oracle RDBMS as well.
It is widely used for online transaction processing, data warehousing, and enterprise grid computing.
Q #2) How will you identify Oracle Database Software Release?
Ans: Oracle follows a number of format for every release.
For Example, release 10.1.0.1.1 can be referred as below mentioned:
10: Major DB Release Number
1: DB Maintenance Release Number
0: Application Server Release Number
1: Component Specific Release Number
1: Platform Specific Release Number
Q #3) How will you differentiate between VARCHAR & VARCHAR2?
Ans: Both VARCHAR & VARCHAR2 are Oracle data types that are used to store character strings of variable length.
VARCHAR can store characters up to 2000 bytes while VARCHAR2 can store up to 4000 bytes.
VARCHAR will hold the space for characters defined during declaration even if all of them are not used whereas VARCHAR2 will release the unused space.
Q #4) What is the difference between TRUNCATE & DELETE command?
Ans: Both the commands are used to remove data from a database.
The finer differences between the two include:
TRUNCATE is a DDL operation while DELETE is a DML operation.
TRUNCATE drops the structure of a database and hence cannot be rolled back while DELETE command can be rolled back.
The TRUNCATE command will free the object storage space while the DELETE command does not.
Q #5) What is meant by RAW datatype?
Ans: RAW datatype is used to store variable-length binary data or byte strings.
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)
Q #6) What is meant by Joins? List out the types of joins.
Ans: Joins are used to extract data from multiple tables using some common column or condition.
There are various types of Joins as listed below:
INNER JOIN
OUTER JOIN
CROSS JOINS or CARTESIAN PRODUCT
EQUI JOIN
ANTI JOIN
SEMI JOIN
Q #7) What is the difference between SUBSTR & INSTR functions?
Ans: SUBSTR function returns the sub-part identified by numeric values from the provided string.
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.
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?
Ans: We can use the below example query to fetch the duplicate records.
SELECT EMP_NAME, COUNT (EMP_NAME)
FROM EMP
GROUP BY EMP_NAME
HAVING COUNT (EMP_NAME) > 1;
Q #9) How does the ON-DELETE-CASCADE statement work?
Ans: Using ON DELETE CASCADE will automatically delete a record in the child table when the same is deleted from the parent table. This statement can be used with Foreign Keys.
We can add ON DELETE CASCADE option on an existing table using the below set of commands.
Syntax:
ALTER TABLE CHILD_T1 ADD CONSTRAINT CHILD_PARENT_FK REFERENCES
PARENT_T1 (COLUMN1) ON DELETE CASCADE;
Q #10) What is a NVL function? How can it be used?
Ans: NVL is a function, which helps the user to substitute a value if null is encountered for an expression.
It can be used as the below syntax.
[NVL (Value_In, Replace_With)]

Leave a Reply