SQL Dialect Reference (MySQL, PostgreSQL, SQLite)

Moving between databases or writing portable SQL? Look up the task once and see the exact syntax for all three popular open-source databases.

Funziona nel tuo browser. I tuoi file non lasciano mai il dispositivo. Scopri come verificarlo

…

Come si usa

  1. 1
    Search a task

    In plain words.

  2. 2
    Pick a section

    Or search all.

  3. 3
    Choose dialects

    One or all three.

  4. 4
    Read the notes

    Versions and pitfalls.

  5. 5
    Copy the syntax

    For your database.

  6. 6
    Download CSV

    Keep it handy.

Informazioni su questo strumento

SQL is a standard, but every database speaks its own dialect. An upsert is ON DUPLICATE KEY UPDATE in MySQL and ON CONFLICT in PostgreSQL and SQLite. Auto-increment keys, boolean columns, date arithmetic, string concatenation, case-insensitive search and JSON access all differ, and so do the commands for listing tables or backing up a database. Developers switching projects, migrating from SQLite in development to PostgreSQL in production, or writing code that must support several databases spend a lot of time looking these up one by one. This reference puts 57 everyday tasks side by side for MySQL 8, PostgreSQL 16 and SQLite 3.45, in sections for connecting and inspecting, creating and changing tables, inserting and updating, querying, dates, JSON, users and safety, and backups. Search in plain words such as upsert, rename column or start of month, show one dialect or all three, read the notes on version requirements and pitfalls, and download the sheet as CSV.

The biggest differences

- Identity columns: AUTO_INCREMENT, GENERATED ALWAYS AS IDENTITY, or INTEGER PRIMARY KEY in SQLite. - Types: PostgreSQL has real BOOLEAN, UUID and JSONB types; MySQL stores booleans as small integers; SQLite uses flexible type affinity unless a table is declared STRICT. - Upserts: MySQL's ON DUPLICATE KEY UPDATE uses any unique key; PostgreSQL and SQLite name the conflict target. - Case sensitivity: MySQL's default collation compares text without case; PostgreSQL compares exactly and offers ILIKE. - Dates: each has its own functions for adding intervals and formatting.

Portable habits

Use standard SQL where possible: CASE instead of IF or IIF, COALESCE instead of IFNULL, string concatenation through a query builder or ORM, ISO date strings, and explicit ORDER BY for deterministic results. Test migrations against the production database, not only SQLite.

Safety notes

Commands that delete data, such as TRUNCATE, DROP COLUMN and restores, are flagged in the notes. MySQL commits schema changes immediately, so they cannot be rolled back inside a transaction. SQLite only enforces foreign keys when the pragma is switched on.

Versions

Features like RETURNING, UPDATE FROM, DROP COLUMN and the JSON arrow operators need recent SQLite versions, and window functions and CTEs need MySQL 8. The notes say where a minimum version applies.

Moving between databases

When migrating, export the schema first and translate types and defaults, then move data in batches and compare row counts and checksums. Run the application's test suite against the new database before switching, because small differences in sorting, collation and null handling only show up with real queries.

Limits

This is a quick reference for common tasks, not a complete grammar. MariaDB mostly follows the MySQL column but has differences of its own. Check the official manual for options and edge cases before running commands on production data.

Esempio svolto

Searching upsert shows INSERT ... ON DUPLICATE KEY UPDATE for MySQL, INSERT ... ON CONFLICT (id) DO UPDATE SET n = EXCLUDED.n for PostgreSQL and the same with lower-case excluded for SQLite, plus a note that MySQL 8.0.20 prefers a row alias over VALUES().

In breve

Domande frequenti

Is PostgreSQL syntax closer to the SQL standard?

Generally yes, though all three add their own extensions.

How do I do an upsert in SQLite?

INSERT ... ON CONFLICT (column) DO UPDATE, from version 3.24.

Why does LIKE ignore case in MySQL?

Because of the default case-insensitive collation.

Does SQLite enforce foreign keys?

Only after PRAGMA foreign_keys = ON on each connection.

Can I download the sheet?

Yes, as CSV.

Does it connect to my database?

No. It is a reference only.

Completamente gratisNessun costo, nessuna registrazione
I file restano privatiTutto funziona nel tuo browser
Facile nella tua linguaDisponibile in molte lingue