SQL Dialect Rosetta Stone: Oracle, PostgreSQL, MySQL & SQLite
Side-by-side verified SQL translations and subtle behavioral gotchas for engineers migrating between Oracle, PostgreSQL, MySQL, and SQLite.
Cross-Engine SQL Translations (12 Topics)
UPSERT (MERGE INTO vs ON CONFLICT vs ON DUPLICATE KEY)
Atomic insert-or-update syntax differs sharply across Oracle, PostgreSQL, MySQL, and SQLite.
Hierarchy & GraphsHierarchical Queries (CONNECT BY PRIOR vs WITH RECURSIVE)
Translating legacy Oracle START WITH / CONNECT BY PRIOR trees into ANSI WITH RECURSIVE CTEs.
PaginationPagination & Top-N (ROWNUM / FETCH FIRST vs LIMIT OFFSET)
Safe Top-N and keyset pagination syntax across engines without falling into Oracle's ROWNUM ordering trap.
ExpressionsNULL Coalescing (NVL / NVL2 vs COALESCE / IFNULL)
Subtle short-circuit evaluation and type coercion differences between Oracle NVL and ANSI COALESCE.
Data TypesEmpty String '' vs NULL Trap (Oracle vs PostgreSQL / MySQL / SQLite)
The #1 silent bug during Oracle-to-PostgreSQL migrations: Oracle treats '' as NULL, whereas PostgreSQL, MySQL, and SQLite treat '' as a valid 0-length string.
Dates & TimeDate Truncation & Intervals (TRUNC / SYSDATE vs DATE_TRUNC / INTERVAL)
Index-friendly date truncation and interval math across all four SQL dialects.
ExpressionsConditional Logic (Oracle DECODE vs ANSI CASE WHEN)
Migrating Oracle DECODE() expressions to portable ANSI CASE WHEN without losing NULL equality semantics.
AggregationString Aggregation (LISTAGG vs STRING_AGG vs GROUP_CONCAT)
Concatenating grouped row values into a sorted delimited string across SQL engines.
DDL & KeysAuto-Increment & Sequences (GENERATED AS IDENTITY vs SERIAL vs AUTO_INCREMENT)
Modern primary key generation syntax across Oracle 12c+, PostgreSQL 10+, MySQL 8, and SQLite.
DML & WritesReturning Inserted/Updated Rows (RETURNING INTO vs RETURNING)
Fetching generated IDs or updated values in a single round-trip without a second SELECT.
Pattern MatchingRegular Expressions in SQL (REGEXP_LIKE vs ~ vs REGEXP)
POSIX regex matching operators and index behavior across SQL engines (pair with mcregex.com to audit ReDoS safety).
Query TuningCTE Optimization & Materialization (MATERIALIZE Hint vs AS MATERIALIZED)
Controlling whether Common Table Expressions are inlined (predicate pushdown) or materialized once.