Skip to content

Kotmin/PL-SQL-Lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PL-SQL lab

What This Provides

A lightweight, reproducible Oracle 23c Free environment for SQL + PL/SQL practice.

Features:

  • Docker-based Oracle DB with persistent volume
  • Automatic schema + seed initialization on first run
  • Make commands for common workflows
  • Ability to run custom SQL scripts
  • Easy full reset / rollback
  • Seed data included for immediate experimentation

πŸ“¦ Directory layout

plsql-lab/
β”œβ”€ docker-compose.yml
β”œβ”€ .env                       # secrets & config (not checked in)
β”œβ”€ db/
β”‚  β”œβ”€ init/                   # runs ONLY on first database creation
β”‚  β”‚   β”œβ”€ 01_schema.sql
β”‚  β”‚   └─ 02_seed_data.sql
β”‚  └─ startup/                # runs at EVERY container start
β”‚      └─ 01_after_start.sql
β”œβ”€ scripts/
β”‚  β”œβ”€ seed.sh                 # apply any .sql file(s) on demand
β”‚  └─ reset.sh                # stop & wipe volumes & re-create
└─ Makefile

Make scripts executable

chmod +x scripts/*.sh

🐳 Quickstart (Docker Only)

Start the environment:

docker compose up -d

Check logs:

docker compose logs -f oracle

Stop:

docker compose down

Full reset (recreates DB + reruns init scripts):

docker compose down -v && docker compose up -d

🧰 Quickstart (Using Make)

Start DB:

make up

Stop DB:

make down

Logs:

make logs

Open shell:

make sh

Run any SQL file as APP_USER:

make seed FILE=path/to/script.sql

Full reset (fresh DB + auto-seed):

make reset

Clone repo

git clone git@github.com:Kotmin/PL-SQL-Lab.git

🧠 Connect to IDE

Test default state with

SHOW USER;

SELECT table_name FROM user_tables ORDER BY table_name;

-- Which schema am I?
SHOW USER;  


SELECT owner, table_name
FROM   all_tables
WHERE  table_name IN ('STUDENCI','EGZAMINY','EGZAMINATORZY','OSRODKI','PRZEDMIOTY')
ORDER  BY owner, table_name;
Working with VSC

To install connect and use lab within Visual Studio Code

Details

visual studio code oracle sql developer for db conn

visual studio code connection setup visual studio code new sql

new command

Enable display to console(in that preset it should be already enabled)

SET SERVEROUTPUT ON;

BEGIN
  DBMS_OUTPUT.PUT_LINE('5');
END;
/

Working with DataGrip

To install connect and use lab with DataGrip

Details

g connection page

oracle dialect

Driver

alt text

assign shortcut for run code alt + enter

alt text

Enable DBMS_OUTPUT

enable dbms output

trigger DBMS output

Enable display to console(in that preset it should be already enabled)

SET SERVEROUTPUT ON;

BEGIN
  DBMS_OUTPUT.PUT_LINE('5');
END;
/

🌱 Seed & Initialization

πŸ”§ Automatic Initialization

Files in:

db/init/

run once on first DB creation:

  • 01_schema.sql β€” creates tables
  • 02_seed_data.sql β€” loads example data

Re-run by performing a reset:

make reset

πŸ” Startup Scripts

Files in:

db/startup/

run every time the container starts (useful for views, helpers, maintenance).


πŸ“Š Testing the Environment

Test that PL/SQL + DBMS_OUTPUT works:

SET SERVEROUTPUT ON;

BEGIN
  DBMS_OUTPUT.PUT_LINE('Oracle Lab OK');
END;
/

Test your sample data:

SELECT COUNT(*) FROM studenci;
SELECT COUNT(*) FROM egzaminy;

🧹 Troubleshooting

❗ β€œTable does not exist” / ORA-00942

Database schema didn’t initialize.
Fix:

make reset

❗ Seed script not running

Use:

make seed FILE=yourfile.sql

❗ DBMS_OUTPUT not showing

Enable in your client:

SET SERVEROUTPUT ON;

❗ β€œDatabase already initialized”

Remove volume + restart:

make reset

πŸ“˜ Notes

  • Oracle version: 23c Free
  • Main schema: APP_USER
  • Service name for connections: FREEPDB1
  • Data persists until you reset the volume
  • Safe sandbox β€” reset anytime for a clean environment

About

Lightweight Oracle 23c Free PL/SQL lab environment. 🐳 Includes auto-initialized schema + seed data, Makefile utilities, and ready-to-use Docker setup for SQL/PLSQL learning, testing, and experimentation. Perfect for students, backend engineers, DB developers, and anyone exploring PL/SQL locally. #oracle #plsql #docker #database #devops

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors