PL/Sql Interview Questions Part 2
1. What is PL/SQL?
- PL/SQL stands for procedural language extension to SQL.
- It supports procedural features of programming language and SQL both.
- It was developed by Oracle Corporation in early of 90’s to enhance the capabilities of SQL.
2. What is the purpose of using PL/SQL?
- PL/SQL is an extension of SQL.
- While SQL is non-procedural, PL/SQL is a procedural language designed by Oracle.
- It is invented to overcome the limitations of SQL.
3. What are the most important characteristics of PL/SQL?
A list of some notable characteristics:
- PL/SQL is a block-structured language.
- It is portable to all environments that support Oracle.
- PL/SQL is integrated with the Oracle data dictionary.
- Stored procedures help better sharing of application.
4. What is PL/SQL table? Why it is used?
- Objects of type tables are called PL/SQL tables that are modeled as database table.
- We can also say that PL/SQL tables are a way to providing arrays.
- Arrays are like temporary tables in memory that are processed very quickly.
- PL/SQL tables are used to move bulk data.
- They simplifies moving collections of data.
5. What are the datatypes available in PL/SQL?
There are two types of datatypes in PL/SQL:
- Scalar datatypes Example are NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN etc.
- Composite datatypes Example are RECORD, TABLE etc.
6. What is the basic structure of PL/SQL?
PL/SQL uses BLOCK structure as its basic structure.
Each PL/SQL program consists of SQL and PL/SQL statement which form a PL/SQL block.
PL/SQL block contains 3 sections.
- The Declaration Section (optional)
- The Execution Section (mandatory)
- The Exception handling Section (optional)
8. What is exception? What are the types of exceptions?
Exception is an error handling part of PL/SQL.
There are two type of exceptions: pre_defined exception and user_defined exception.
9. How to write a single statement that concatenates the words ?Hello? and ?World? and assign it in a variable named Greeting?
Greeting := ‘Hello’ || ‘World’;
10. Does PL/SQL support CREATE command?
No, PL/SQL doesn’t support the data definition commands like CREATE.
11. Write a unique difference between a function and a stored procedure.
A function returns a value while a stored procedure doesn’t return a value.
12. How exception is different from error?
- Whenever an Error occurs Exception arises.
- Error is a bug whereas exception is a warning or error condition.
13. What is the main reason behind using an index?
By using an Index we can access data blocks Faster in the table.
14. What are PL/SQL exceptions? Tell me any three.
- Zero_error etc.
15. How do you declare a user-defined exception?
You can declare the User defined exceptions under the DECLARE section, with the keyword EXCEPTION.