Oracle vs. MySQL Differences — Syntax, Functions, and Sequences
| Item | Oracle | MySQL |
|---|---|---|
| Auto increment | SEQUENCE | AUTO_INCREMENT |
| String concatenation | || | CONCAT() |
| NULL handling | NVL() | IFNULL() / COALESCE() |
| Pagination | ROWNUM / FETCH FIRST | LIMIT / OFFSET |
| Date function | SYSDATE | NOW() |
| Empty string | Same as NULL | Different from NULL |
Auto-Increment Keys
-- Oracle
CREATE SEQUENCE user_seq START WITH 1 INCREMENT BY 1;
INSERT INTO users VALUES (user_seq.NEXTVAL, 'Hoon');
-- MySQL
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50)
);
INSERT INTO users (name) VALUES ('Hoon');
Pagination Queries
-- Oracle 12c+
SELECT * FROM posts
ORDER BY created_at DESC
OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;
-- Oracle 11g and earlier
SELECT * FROM (
SELECT ROWNUM rn, t.* FROM (
SELECT * FROM posts ORDER BY created_at DESC
) t WHERE ROWNUM <= 10
) WHERE rn > 0;
-- MySQL
SELECT * FROM posts ORDER BY created_at DESC LIMIT 10 OFFSET 0;
NULL Handling
-- Oracle
SELECT NVL(phone, '미등록') FROM users;
SELECT NVL2(phone, '있음', '없음') FROM users;
-- MySQL
SELECT IFNULL(phone, '미등록') FROM users;
SELECT IF(phone IS NOT NULL, '있음', '없음') FROM users;
-- Common (ANSI SQL)
SELECT COALESCE(phone, mobile, '미등록') FROM users;
Date Handling
-- Oracle
SELECT SYSDATE, TRUNC(SYSDATE), TO_CHAR(SYSDATE, 'YYYY-MM-DD') FROM DUAL;
SELECT ADD_MONTHS(SYSDATE, 1) FROM DUAL;
-- MySQL
SELECT NOW(), DATE(NOW()), DATE_FORMAT(NOW(), '%Y-%m-%d');
SELECT DATE_ADD(NOW(), INTERVAL 1 MONTH);
MERGE / UPSERT
-- Oracle MERGE
MERGE INTO users t USING (SELECT 1 id, 'Hoon' name FROM DUAL) s
ON (t.id = s.id)
WHEN MATCHED THEN UPDATE SET t.name = s.name
WHEN NOT MATCHED THEN INSERT VALUES (s.id, s.name);
-- MySQL
INSERT INTO users (id, name) VALUES (1, 'Hoon')
ON DUPLICATE KEY UPDATE name = VALUES(name);
What Gets Hard in Production
- Oracle and MySQL differ not only in features but in operational assumptions, licensing, tooling culture, and enterprise fit.
- The wrong comparison asks which database is “better” in general instead of which risk profile and workload each one supports.
- Migration cost can outweigh feature gain if surrounding expertise is ignored.
Architecture Decisions That Matter
- Evaluate by workload criticality, operational maturity, ecosystem fit, and budget constraints.
- Include backup, HA, observability, and DBA skill depth in the decision, not just SQL feature lists.
- Treat vendor posture and long-term support expectations as architecture inputs.
Practical Example
A practical selection matrix often looks like this:
Oracle -> large enterprise controls, mature DBA operations, complex legacy integration
MySQL -> broad commodity ecosystem, lower cost sensitivity, simpler operational footprint
Anti-Patterns to Avoid
- Comparing only benchmark headlines.
- Ignoring licensing and operational staffing realities.
- Assuming migration is mainly about SQL syntax compatibility.
Operational Checklist
- List non-functional requirements before feature comparison.
- Estimate migration effort beyond schema conversion.
- Assess backup, failover, and monitoring tooling readiness.
- Review available team expertise honestly.
Final Judgment
Oracle versus MySQL is a context decision, not a universal ranking. The better choice is the one whose operational and business model the organization can actually sustain.
Continue Reading
Related posts
A Practical Guide to SQL Performance Optimization
A production-focused guide to SQL tuning that treats performance as a workload problem. Learn how to read plans, reduce data access, tune indexes honestly, and avoid premature query heroics.
🗄️ DatabaseDatabase Learning Path: Beginner to Advanced
A structured database roadmap from indexing and query basics to replication, partitioning, and schema-safe operations.
📈 TrendsPostgreSQL 18 Trends: What Actually Matters in Practice
PostgreSQL 18 is more than an upgrade headline. AIO, skip scan, better post-upgrade recovery, OAuth, and generated columns all point to a release focused on operational cost reduction.
🚀 DevOpsKubernetes Advanced Operations — HPA, Resource Management, and Pod Scheduling
This article explains Kubernetes operations not as a collection of settings but from the perspective of resource placement and resilience. It covers when and how to use requests/limits, HPA, affinity, taints, PDBs, and probes in real environments.
Next Path