This project demonstrates how to build, train, and evaluate a machine learning classification model using pure SQL on an Oracle Autonomous Database (19c), following the workflow from the article:
Machine Learning with SQL — It’s Easier Than You Think by Dario Radečić.
We replicate the Iris dataset classification example using Oracle’s built‑in Machine Learning capabilities (DBMS_DATA_MINING) and SQL Developer.
iris-ml.sql— SQL script to create table, load data, train model, and evaluate predictions.iris.csv— Iris dataset (150 rows, 5 features).wallet.zip— Oracle Cloud ATP wallet for secure DB connection.screenshots/— example outputs.
✅ Oracle Cloud Free Tier account
✅ Autonomous Transaction Processing (ATP) database created & running
✅ SQL Developer (standalone or VS Code extension)
✅ Wallet downloaded for ATP database
These steps walk you through setting up everything from scratch in Oracle Cloud.
- 👉 https://www.oracle.com/cloud/free/
- Free Tier is sufficient for this project.
- Go to https://cloud.oracle.com/
- ☰ → Oracle Database → Autonomous Database → Create Autonomous Database
- Use:
- Workload Type: Transaction Processing
- Database Version: 19c
- Always Free: ✅ enabled if available
- Click Create Autonomous Database
- When the ATP is ready (Status = Available), open it.
- Click DB Connection → Download Wallet
- Set a password, download
wallet.zip, and save it to your project folder.
- From the ATP details page, open SQL Developer Web under Tools
- Log in as
ADMINwith your password - Go to Data Load → Select schema (e.g.,
ADMIN) → choose tableIRIS(after running the script below) - Upload
iris.csv - 🔴 Important: The
IDcolumn must be present and unique in the uploaded data- If your CSV does not contain the
IDcolumn:- After uploading, run this query in SQL Developer or VS Code to generate it:
ALTER TABLE IRIS ADD (ID NUMBER); UPDATE IRIS SET ID = ROWNUM;
- After uploading, run this query in SQL Developer or VS Code to generate it:
- If your CSV does not contain the
- Map the columns to:
ID,SEPAL_LENGTH,SEPAL_WIDTH,PETAL_LENGTH,PETAL_WIDTH,SPECIES - Click Next → Load Data
- In VS Code: go to Extensions → search Oracle Developer Tools for VS Code
- Install it
- Open the Oracle SQL Developer panel (database icon)
- Click
+to add a new connection:- Connection Name:
ATP19c - Username:
ADMIN - Password: (what you set for ATP)
- Wallet Location: path to
wallet.zip - Service Name: choose from the wallet (e.g.,
yourdbname_high)
- Connection Name:
- Right‑click the saved connection →
Connect - Open
iris-ml.sql - Run the script:
- Right-click →
Run Query, or - Select all and hit the "Run" icon
- Right-click →
- The script:
- Creates the
IRIStable - Creates a settings table
- Trains a Decision Tree model
- Predicts on the same data
- Calculates accuracy
- Displays a confusion matrix via SQL
- Creates the
✅ You’ll see predictions like setosa, virginica, etc., and model accuracy around 95–97%.
- Model:
IRIS_MODEL - Accuracy: ~96%
- Confusion Matrix: see script output.
This project is a replication of the excellent article:
Machine Learning with SQL — It’s Easier Than You Think by Dario Radečić..
Implemented on Oracle ATP Free Tier with SQL Developer.
See LICENSE for details.