00:00

MySQL Vs Oracle

Last updated: 4 min read

MySQL and Oracle Database are both relational database systems, and both are owned by Oracle Corporation. They are still very different products. MySQL is a free, lightweight, easy-to-run database popular for web applications. Oracle Database is a commercial, feature-rich enterprise database used by banks, telecoms and governments. This page compares them point by point.

1. Overview

MySQLOracle Database
First release1995 (MySQL AB)1979 (Relational Software Inc., later Oracle)
OwnerOracle Corporation (since 2010)Oracle Corporation
LicenceGPL Community Edition (free) + commercial Enterprise EditionCommercial; free Oracle Database Free edition with limits
Typical usersWeb and SaaS apps, start-ups, LAMP stacks, read-heavy sitesLarge enterprises, banking, ERP, data warehouses
Procedural languageSQL/PSM-style stored proceduresPL/SQL (very rich, with packages)
Default port33061521

2. Architecture and Structure

How MySQL and Oracle organise objectsIn MySQL a server holds databases, and database means the same as schema. In Oracle a container database holds pluggable databases, each pluggable database holds schemas, and a schema belongs to a user.MySQLServer (mysqld)database = schema: shoptables, views, routinesdatabase = schema: hrtables, views, routinesOracle DatabaseInstance + container database (CDB)Pluggable database (PDB)schema SHOP (user)schema HR (user)
Figure 1: in MySQL, database and schema mean the same thing. In Oracle, schemas live inside a (pluggable) database and each schema belongs to a user.
  • Process model: MySQL runs one process with a thread per connection. Oracle runs an instance of several background processes with shared memory (SGA).
  • Storage: MySQL delegates storage to pluggable engines (InnoDB). Oracle has one integrated engine with tablespaces, data files, redo and undo.
  • Users and schemas: in Oracle, creating a user creates a schema of the same name. In MySQL users and databases are independent.

3. SQL Dialect Differences

TaskMySQLOracle
Top N rowsLIMIT 5FETCH FIRST 5 ROWS ONLY (12c+) or ROWNUM <= 5
Auto-numbered keyINT AUTO_INCREMENTGENERATED AS IDENTITY (12c+) or a SEQUENCE
Variable-length textVARCHAR(n)VARCHAR2(n)
NumbersINT, DECIMAL, DOUBLENUMBER(p,s) for almost everything
Select without a tableSELECT NOW();SELECT SYSDATE FROM dual; (Oracle 23ai allows no FROM)
String concatenationCONCAT(a, b)a || b
Empty string'' is an empty string, different from NULL'' is treated as NULL
If-nullIFNULL(x, 0) / COALESCENVL(x, 0) / COALESCE
Boolean columnBOOLEAN (TINYINT(1))NUMBER(1); native BOOLEAN only from 23ai
DDL in transactionsImplicit commitImplicit commit

Here is the MySQL side of a few of these, run on MySQL:

mysql-side.sql
CREATE DATABASE compare_demo;
USE compare_demo;
CREATE TABLE staff (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30), nickname VARCHAR(20), salary DECIMAL(9,2));
INSERT INTO staff (name, nickname, salary) VALUES
('Anil', '', 52000), ('Bina', NULL, 61000), ('Chris', 'CJ', 47000), ('Deepa', 'Dee', 75000);

SELECT name,
       nickname = ''        AS is_empty_string,
       nickname IS NULL     AS is_null,
       IFNULL(nickname, '-') AS shown
FROM staff;

Result: 4 rows

nameis_empty_stringis_nullshown
Anil10
BinaNULL1-
Chris00CJ
Deepa00Dee
In Oracle, Anil's empty nickname would be stored as NULL, so is_empty_string logic behaves differently. This is a classic migration surprise.
top-n-mysql.sql
SELECT name, salary FROM staff ORDER BY salary DESC LIMIT 2;

Result: 2 rows

namesalary
Deepa75000.00
Bina61000.00
top-n-oracle.sql
SELECT name, salary FROM staff ORDER BY salary DESC FETCH FIRST 2 ROWS ONLY;

4. Feature Comparison

FeatureMySQLOracle
ACID transactionsYes (InnoDB)Yes
Default isolation levelREPEATABLE READREAD COMMITTED
Materialized viewsNo (use summary tables + events)Yes, with query rewrite
PartitioningRange, list, hash, keyMany types incl. interval and reference (extra-cost option)
Flashback (view past data)NoFlashback Query / Table / Database
Clustering for HAGroup Replication, InnoDB ClusterReal Application Clusters (RAC), Data Guard
JSONJSON type and functionsJSON type, JSON-relational duality views (23ai)
Backup toolsmysqldump, MySQL Shell, Enterprise BackupRMAN, Data Pump
Management GUIMySQL WorkbenchSQL Developer, Enterprise Manager

5. Cost and Licensing

  • MySQL Community is free for any use under the GPL. If you ship MySQL inside a closed-source product, you may need a commercial licence.
  • Oracle Database Enterprise Edition is licensed per processor or named user, and many features (partitioning, RAC, advanced security) are paid options. Oracle Database Free exists for learning and small apps, with CPU, memory and storage caps.
  • Both are available as managed cloud services, priced by usage.

6. When to Choose Which

Choose MySQL when…Choose Oracle when…
You want a free, quick-to-set-up databaseThe organisation already runs Oracle and has Oracle DBAs
You are building a web or mobile back endYou need RAC, Data Guard, flashback or advanced partitioning
Workloads are mostly simple, fast reads and writesYou run very large, complex enterprise or warehouse workloads
The team knows open-source tools (Linux, Docker, Spring Boot)Your vendor software (ERP, banking) requires Oracle

7. Summary

  • Both are relational and owned by Oracle; MySQL is free and lightweight, Oracle Database is commercial and enterprise-focused.
  • Oracle uses instances, PDBs and user-owned schemas; in MySQL a database is a schema.
  • Dialect differences: LIMIT vs FETCH FIRST, AUTO_INCREMENT vs identity/sequence, VARCHAR vs VARCHAR2, and empty strings becoming NULL in Oracle.
  • Oracle adds features such as materialized views, flashback and RAC; MySQL focuses on simplicity, speed and cost.