Top 100 PL/SQL Interview Questions (Sections-wise)
1. Basics (1–15)
-
What is PL/SQL and its advantages over SQL?
-
What are the differences between SQL and PL/SQL?
-
What are the components of a PL/SQL block?
-
What are anonymous blocks? Give an example.
-
Explain %TYPE and %ROWTYPE.
-
What are the data types available in PL/SQL?
-
Difference between CHAR and VARCHAR2 in PL/SQL.
-
What are literals and identifiers?
-
Explain DECLARE, BEGIN, EXCEPTION, END in PL/SQL block.
-
Difference between PL/SQL variables and constants.
-
What is the difference between BOOLEAN and NUMBER for flags?
-
Explain nested blocks in PL/SQL.
-
How are NULLs handled in PL/SQL?
-
What are PL/SQL expressions and operators?
-
Explain control statements in PL/SQL (IF, CASE, LOOP).
2. Cursors (16–30)
-
What is a cursor? Difference between implicit and explicit cursors.
-
How do you declare a cursor in PL/SQL?
-
What is %FOUND, %NOTFOUND, %ROWCOUNT, %ISOPEN attributes?
-
How do you fetch records using a cursor?
-
Difference between FOR loop cursor and WHILE loop cursor.
-
How do you pass parameters to a cursor?
-
What is a REF CURSOR? Difference between weak and strong REF CURSOR.
-
Explain cursor FOR loop.
-
How to use multiple cursors in PL/SQL.
-
What are cursor variables?
-
Difference between explicit cursor and cursor variable.
-
How to close a cursor explicitly?
-
How to handle exceptions in cursors?
-
Can a cursor return more than one row?
-
Difference between implicit cursor and cursor FOR loop.
3. Procedures and Functions (31–45)
-
Difference between procedure and function.
-
Syntax to create a procedure.
-
How to create a function in PL/SQL.
-
Difference between stored and anonymous procedures/functions.
-
Explain IN, OUT, IN OUT parameters.
-
Can a procedure return a value?
-
How to call a procedure from SQL*Plus or another PL/SQL block?
-
Difference between procedure overloading and function overloading.
-
How to handle exceptions inside procedures/functions?
-
Can a function perform DML operations?
-
Difference between autonomous transaction and normal procedure.
-
Explain PRAGMA AUTONOMOUS_TRANSACTION.
-
How to pass a table/record as parameter?
-
How to debug PL/SQL procedures and functions.
-
How to handle NULL input parameters in functions/procedures.
4. Triggers (46–60)
-
What is a trigger?
-
Types of triggers in Oracle (BEFORE, AFTER, INSTEAD OF).
-
Difference between row-level and statement-level triggers.
-
How to create a trigger in PL/SQL?
-
What are INSTEAD OF triggers?
-
What are compound triggers?
-
Difference between BEFORE INSERT and AFTER INSERT triggers.
-
Can a trigger call a procedure?
-
What are mutating table errors?
-
How to avoid mutating table errors?
-
Explain trigger timing and events.
-
Can triggers perform COMMIT or ROLLBACK?
-
Difference between system triggers and DML triggers.
-
How to disable or drop a trigger?
-
Use cases for triggers in real projects.
5. Packages (61–70)
-
What is a package in PL/SQL?
-
Advantages of using packages.
-
Difference between package specification and package body.
-
How to create a package.
-
Can a package have private procedures/functions?
-
How to initialize a package using package initialization block?
-
Difference between public and private objects in a package.
-
How does package help in performance optimization?
-
How to call a package procedure/function?
-
Difference between standalone procedure and packaged procedure.
6. Performance & Optimization (71–80)
-
How to improve PL/SQL performance?
-
Difference between BULK COLLECT and normal SELECT INTO loop.
-
Explain FORALL statement.
-
Difference between implicit and explicit cursors in terms of performance.
-
What is SQL%ROWCOUNT usage?
-
How to avoid context switching in PL/SQL.
-
Difference between PL/SQL tables, VARRAYs, nested tables.
-
Explain use of indexing in PL/SQL performance.
-
Difference between PL/SQL collections and database tables.
-
How to profile PL/SQL code using DBMS_PROFILER.
7. Advanced PL/SQL (81–90)
-
What is dynamic SQL? Explain DBMS_SQL and EXECUTE IMMEDIATE.
-
Difference between static and dynamic SQL.
-
How to handle exceptions in dynamic SQL.
-
What are PL/SQL collections? Explain types.
-
Difference between associative array, nested table, and VARRAY.
-
How to loop through collections efficiently.
-
What is bulk binding?
-
How to implement recursive PL/SQL procedures/functions.
-
Difference between autonomous transaction and regular transaction.
-
Explain the use of DBMS_OUTPUT.PUT_LINE and debugging.
8. Exception Handling (91–95)
-
How exceptions are handled in PL/SQL.
-
Difference between predefined and user-defined exceptions.
-
How to raise an exception manually.
-
What is RAISE_APPLICATION_ERROR?
-
Difference between NO_DATA_FOUND, TOO_MANY_ROWS, ZERO_DIVIDE exceptions.
9. Miscellaneous / Scenario-based (96–100)
-
How to implement a hierarchy using recursive queries in PL/SQL.
-
Difference between triggers and constraints.
-
How to create log tables and auditing using triggers.
-
How to handle large objects (CLOB, BLOB) in PL/SQL.
-
Explain PL/SQL packages for real-time project use cases.
No comments:
Post a Comment