Oracle Database is still at the core of banking, insurance, telecom and ERP systems, and companies keep hiring PL/SQL developers to build and tune it. These PL/SQL interview questions cover what Oracle PL/SQL developer, database developer and ETL developer interviews ask most often.
The top 20 questions move from PL/SQL basics to bulk processing, performance tuning and real-world scenario questions for experienced developers.
PL/SQL basics
1. What is PL/SQL and how is it different from SQL?
SQL is a declarative language for querying and changing data. PL/SQL is Oracle’s procedural extension that adds variables, loops, conditions, exception handling, procedures, functions, packages and triggers. A PL/SQL block can run many SQL statements in one call, which cuts network round trips.
2. What is the structure of a PL/SQL block?
A block has an optional DECLARE section for variables, cursors and types, a mandatory BEGIN ... END executable section, and an optional EXCEPTION section for error handling. Blocks can be anonymous or named (procedures, functions, triggers).
3. What is the difference between a procedure and a function?
Both are stored subprograms. A function must return a single value and can be called from SQL if it has no side effects; a procedure does not have to return a value and returns data through OUT parameters. Procedures are used for actions, functions for computations.
4. What are %TYPE and %ROWTYPE?
%TYPE declares a variable with the same data type as a column or another variable; %ROWTYPE declares a record matching a table row or cursor. Both keep code working when column definitions change.
5. What are packages and why use them?
A package groups related procedures, functions, types, cursors and variables. The specification is the public interface and the body holds the implementation. Packages give encapsulation, better organization, session-level state, and load into memory as a unit for performance.
Cursors and exception handling
6. What is the difference between an implicit and explicit cursor?
Oracle creates implicit cursors for every DML statement and single-row SELECT INTO, exposing attributes like SQL%ROWCOUNT and SQL%FOUND. Explicit cursors are declared for multi-row queries and opened, fetched and closed by the developer, or iterated with a cursor FOR loop.
7. What is a REF CURSOR?
A REF CURSOR is a pointer to a result set that can be opened for different queries at runtime and passed between programs or returned to Java, .NET or Python clients. SYS_REFCURSOR is the predefined weakly typed version.
8. How does exception handling work in PL/SQL?
Errors raise exceptions that jump to the EXCEPTION section. Handle predefined exceptions such as NO_DATA_FOUND, TOO_MANY_ROWS and ZERO_DIVIDE, declare user-defined exceptions, map Oracle errors with PRAGMA EXCEPTION_INIT, and use RAISE_APPLICATION_ERROR for custom error codes between -20000 and -20999. Log SQLCODE, SQLERRM and DBMS_UTILITY.FORMAT_ERROR_BACKTRACE.
9. Why should you avoid WHEN OTHERS THEN NULL?
It silently swallows every error, including real bugs, so data can be left inconsistent with no trace. If you use WHEN OTHERS, log the error and re-raise it.
Triggers, transactions and collections
10. What are triggers and what types exist?
Triggers run automatically on events. Types include row-level and statement-level DML triggers (BEFORE/AFTER INSERT, UPDATE, DELETE), INSTEAD OF triggers on views, compound triggers, DDL triggers and database event triggers such as logon. Use them for auditing and enforcing rules, but keep business logic out of them where possible.
11. What is a mutating table error and how do you fix it?
ORA-04091 occurs when a row-level trigger queries or modifies the table that fired it. Fix it with a compound trigger that collects rows at row level and processes them after the statement, or by redesigning the logic.
12. What is an autonomous transaction?
PRAGMA AUTONOMOUS_TRANSACTION makes a subprogram run in its own independent transaction, so it can commit without affecting the caller. It is commonly used for error logging that must persist even when the main transaction rolls back.
13. What are PL/SQL collections?
Collections are associative arrays (index-by tables), nested tables and VARRAYs. They hold sets of values in memory and are the basis for bulk processing and passing arrays between programs.
Performance tuning
14. What are BULK COLLECT and FORALL?
BULK COLLECT fetches many rows into a collection in one context switch; FORALL sends many DML statements to the SQL engine at once. Together they dramatically speed up row-by-row loops. Use the LIMIT clause to control memory and SAVE EXCEPTIONS to continue past bad rows.
15. What is context switching in PL/SQL?
Each time PL/SQL code runs a SQL statement, control switches between the PL/SQL engine and the SQL engine. Thousands of switches in a loop are slow, which is why set-based SQL and bulk operations are preferred.
16. How do you tune a slow PL/SQL program?
Find the bottleneck with DBMS_PROFILER or DBMS_HPROF, AWR/ASH reports and execution plans. Then replace loops with set-based SQL, use bulk operations, add or fix indexes, use bind variables, gather statistics, and avoid calling functions row by row in SQL. Result cache and pipelined table functions also help in the right cases.
17. What is dynamic SQL and when do you use it?
Dynamic SQL builds statements at runtime with EXECUTE IMMEDIATE or DBMS_SQL, for example for DDL or variable table names. Always use bind variables and validate identifiers with DBMS_ASSERT to prevent SQL injection.
Scenario questions
18. Scenario: a nightly batch that updates millions of rows now takes hours. What do you do?
Check the execution plan and wait events, replace the row-by-row cursor loop with a single MERGE or set-based UPDATE, or with BULK COLLECT and FORALL in batches, disable or defer unnecessary triggers and indexes during the load, use parallel DML if available, and commit in sensible batch sizes.
19. Scenario: how would you remove duplicate rows from a table?
Identify duplicates with ROW_NUMBER() OVER (PARTITION BY key_columns ORDER BY id) and delete rows where the row number is greater than 1, or keep the minimum ROWID per group. Then add a unique constraint to stop it happening again.
20. What is the difference between DELETE, TRUNCATE and DROP?
DELETE removes selected rows, fires triggers, generates undo and can be rolled back. TRUNCATE removes all rows quickly as DDL, resets the high-water mark and cannot be rolled back. DROP removes the table structure and data entirely.
How to prepare for a PL/SQL interview
- Write small programs using cursors, BULK COLLECT, FORALL, packages and exception handling.
- Practice reading execution plans and explaining index choices.
- Review SQL analytic functions (ROW_NUMBER, RANK, LAG, LEAD), joins and subqueries.
- Prepare a story about a performance problem you solved and the measurable improvement.
Strengthen your SQL with our SQL interview questions guide and see data engineer interview questions if you work on ETL pipelines.
Frequently asked questions
What PL/SQL topics are asked most?
Cursors, exception handling, procedures vs. functions, packages, triggers, collections, BULK COLLECT and FORALL, and performance tuning.
Is PL/SQL still in demand?
Yes. Many banks, insurers, telecoms and ERP systems run on Oracle and need PL/SQL developers for maintenance, migrations and new development.
What PL/SQL questions are asked for 5+ years of experience?
Expect performance tuning, bulk processing, partitioning, dynamic SQL, design of packages and APIs, and real production troubleshooting scenarios.
Got the interview? Make sure your resume tells the same story.
Interviewers read your resume right before they talk to you. HiReXL aligns it with the job description’s keywords so your experience and your answers match. HiReXL is built by 4As Consulting, a cloud and DevOps consulting firm. Looking for your next role? Submit your resume for open positions with PanAmerica Inc.


