Tutorials Oracle SQL Tutorial

Packages

Packages: free step-by-step lesson with examples, common mistakes, and interview tips — part of Oracle SQL Tutorial on Toolliyo Academy.

On this page

Oracle SQL Tutorial · Lesson 60 of 96

Packages

Setup & Connect ✓Architecture & SQL ✓DBA & TuningProjects

DBA & Tuning · 3 — Production · ~10 min · Oracle — SQL & PL/SQL

What is this?

A package groups related procedures and functions with a specification (public API) and a body (implementation).

Why should you care?

Large OracleCore modules (payments, KYC, billing) ship as packages so teams share one API.

See it live — copy this example

Run these statements in SQL Developer or SQL*Plus against your lab PDB. Prefer a practice user — not SYS — for application SQL.

CREATE OR REPLACE PACKAGE account_pkg AS
  PROCEDURE credit(p_id NUMBER, p_amount NUMBER);
  FUNCTION get_bal(p_id NUMBER) RETURN NUMBER;
END account_pkg;
/

CREATE OR REPLACE PACKAGE BODY account_pkg AS
  PROCEDURE credit(p_id NUMBER, p_amount NUMBER) AS
  BEGIN
    UPDATE customers SET balance = balance + p_amount WHERE customer_id = p_id;
    COMMIT;
  END;

  FUNCTION get_bal(p_id NUMBER) RETURN NUMBER AS
    v NUMBER;
  BEGIN
    SELECT balance INTO v FROM customers WHERE customer_id = p_id;
    RETURN v;
  END;
END account_pkg;
/

BEGIN
  account_pkg.credit(1, 100);
END;
/
SELECT account_pkg.get_bal(1) FROM dual;

What happened?

  • The package spec lists what others can call.
  • The body contains the code.
  • Call with package_name.procedure_name.

Practice next

  1. Create the package spec, then the body.
  2. Call credit and get_bal.
  3. Describe account_pkg in SQL Developer.
  4. Add a constant MIN_AMOUNT in the package.
  5. Grant EXECUTE on account_pkg to a app user.

Remember

Packages bundle related APIs. Spec = contract; body = code. Call as package.member.

Payments API

Channel apps must not invent their own UPDATE statements.

Outcome: They call account_pkg only.

Interview prep for this lesson

Practice these questions aloud after reading—each links to a full structured answer.

Junior Detailed
Explain SQL queries in the context of Oracle SQL.
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. Explain a bit more How to structure your answer (60–90 seconds) Define SQL queri…
Mid Detailed
What are common mistakes teams make with Schema design when using Oracle SQL?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. Explain a bit more How to structure your answer (60–90 seconds) Define Schema de…
Senior Detailed
How would you debug a production issue related to Transactions in a Oracle SQL application?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. Explain a bit more How to structure your answer (60–90 seconds) Define Transacti…
Junior Detailed
Describe a real-world scenario where Normalization mattered in a Oracle SQL project.
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. Explain a bit more How to structure your answer (60–90 seconds) Define Normaliza…
Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

Oracle SQL Tutorial
Course syllabus

Oracle SQL Tutorial

Oracle — Introduction & Environment Setup
Oracle — Database Startup & Connection
Oracle — Architecture & Internals
Oracle — Database Administration
Oracle — Security & User Management
Oracle — Tablespaces & Storage
Oracle — SQL & PL/SQL
Oracle — Backup, Recovery & Flashback
Oracle — Performance & High Availability
Oracle — Cloud & Modern Features
Oracle — Real-World Projects
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details