Developer and Text Tools

MySQL vs PostgreSQL vs SQLite: The SQL Differences That Bite

The SQL differences between MySQL, PostgreSQL and SQLite that cause bugs: upserts, auto-increment, booleans, case-insensitive search, dates and JSON.

Saizul Amin
Saizul Amin30 Oct 2026 · 3 min read
MySQL vs PostgreSQL vs SQLite: The SQL Differences That Bite

MySQL vs PostgreSQL vs SQLite: The SQL Differences That Bite

SQL is a standard, so in theory a query written for one database runs on another. In practice every database adds its own syntax and behaviour, and the differences show up at the worst moment: when you move from SQLite in development to PostgreSQL in production, join a team that uses MySQL, or write a library that must support all three. The free SQL Dialect Reference puts 57 everyday tasks side by side for MySQL 8, PostgreSQL 16 and SQLite 3.45.

Upserts

Inserting a row or updating it if it already exists is one of the most common jobs, and each database spells it differently. MySQL uses ON DUPLICATE KEY UPDATE, which fires on any unique key. PostgreSQL and SQLite use ON CONFLICT (column) DO UPDATE SET, naming the conflict target and referring to the new values as excluded. MySQL 8.0.20 and later prefer a row alias over the old VALUES() function.

Identity columns and types

Auto-incrementing keys are AUTO_INCREMENT in MySQL, GENERATED ALWAYS AS IDENTITY in modern PostgreSQL, and simply INTEGER PRIMARY KEY in SQLite, where the column becomes an alias for the internal row id.

Types differ more than most people expect. PostgreSQL has real BOOLEAN, UUID, TIMESTAMPTZ and JSONB types. MySQL stores booleans as tiny integers. SQLite uses flexible type affinity: a column declared VARCHAR(10) happily stores a 500-character string unless the table is declared STRICT.

Case and text

MySQL's default collation compares text without regard to case, so WHERE email = '[email protected]' finds the lower-case address. PostgreSQL compares exactly and offers ILIKE and functional indexes on lower(email) instead. SQLite's LIKE ignores case for ASCII letters only. Code that relies on one behaviour breaks silently on another. String concatenation also differs: CONCAT() in MySQL, the standard || operator in PostgreSQL and SQLite.

Dates

Date arithmetic is entirely dialect-specific: DATE_ADD(d, INTERVAL 7 DAY), d + INTERVAL '7 days' and date(d, '+7 days'). Formatting uses DATE_FORMAT, to_char and strftime with different placeholders. SQLite has no date type at all and stores dates as text, numbers or Julian days.

JSON

All three can store and query JSON, with different operators. PostgreSQL's JSONB type supports indexes and containment queries with @>. MySQL uses JSON path expressions such as $.name. SQLite 3.38 and later understand the same arrow operators as the others.

Safety differences

Some differences affect data safety. MySQL commits schema changes immediately, so an ALTER TABLE cannot be rolled back inside a transaction. SQLite enforces foreign keys only after PRAGMA foreign_keys = ON on each connection. TRUNCATE behaves differently around identity counters. The reference notes these cases.

Writing portable SQL

  • Prefer standard constructs: CASE over IF and IIF, COALESCE over IFNULL.
  • Always use ORDER BY when order matters; no database guarantees order otherwise.
  • Store times in UTC with ISO formats.
  • Test against the database you run in production, not only a lighter one.

Inspecting a database you do not know

The first commands you need on an unfamiliar server are the ones that list databases and tables and describe a table's columns. They differ completely between the three systems: SHOW TABLES and DESCRIBE in MySQL, backslash commands such as dt and d in psql, and dot commands with PRAGMA table_info in SQLite. The reference groups them in the first section so you can find your way around quickly.

Step by step

  1. Search for a task in plain words, such as rename column or start of month.
  2. Filter by section if you like.
  3. Show all three dialects or just one.
  4. Read the notes on versions and pitfalls.
  5. Download the sheet as CSV for reference.

Privacy

The reference runs in your browser and never connects to a database.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages