SQL Dialect Cheat Sheet: MySQL, PostgreSQL, SQLite, SQL Server and BigQuery
A complete SQL dialect cheat sheet comparing MySQL, PostgreSQL, SQLite, SQL Server, and BigQuery — identifiers, data types, upserts, pagination, string functions, and more.
SQL Dialect Cheat Sheet: MySQL, PostgreSQL, SQLite, SQL Server and BigQuery
Every major database speaks SQL — but each has its own dialect. This cheat sheet covers the most common syntax differences across all five major databases so you can write the right query the first time.
Identifier Quoting
| Database | Style | Example |
|---|---|---|
| MySQL / MariaDB | Backticks | users |
| PostgreSQL | Double quotes | "users" |
| SQLite | Double quotes or backticks | "users" |
| SQL Server | Square brackets | [users] |
| BigQuery | Backticks | project.dataset.users |
Auto-Increment / Identity Columns
-- MySQL
id INT AUTO_INCREMENT PRIMARY KEY
-- PostgreSQL
id SERIAL PRIMARY KEY
-- SQLite
id INTEGER PRIMARY KEY
-- SQL Server
id INT IDENTITY(1,1) PRIMARY KEY
-- BigQuery
id STRING DEFAULT (GENERATE_UUID())
Boolean Type
-- MySQL
is_active TINYINT(1) DEFAULT 1
-- PostgreSQL
is_active BOOLEAN DEFAULT TRUE
-- SQLite
is_active INTEGER DEFAULT 1
-- SQL Server
is_active BIT DEFAULT 1
-- BigQuery
is_active BOOL DEFAULT TRUE
NULL Fallback Functions
-- MySQL + SQLite
IFNULL(column, 'default')
-- SQL Server
ISNULL(column, 'default')
-- PostgreSQL + BigQuery + Standard SQL
COALESCE(column, 'default')
COALESCE works across all databases and accepts multiple arguments — use it when writing portable SQL.
String Concatenation
-- MySQL + SQL Server
CONCAT(first_name, ' ', last_name)
-- PostgreSQL + SQLite + BigQuery
first_name || ' ' || last_name
Current Timestamp
-- MySQL + PostgreSQL + BigQuery
NOW()
-- SQL Server
GETDATE()
-- SQLite
datetime('now')
Skip Duplicate Inserts
-- MySQL
INSERT IGNORE INTO users (email) VALUES ('a@b.com');
-- PostgreSQL
INSERT INTO users (email) VALUES ('a@b.com')
ON CONFLICT DO NOTHING;
-- SQLite
INSERT OR IGNORE INTO users (email) VALUES ('a@b.com');
-- SQL Server
IF NOT EXISTS (SELECT 1 FROM users WHERE email = 'a@b.com')
INSERT INTO users (email) VALUES ('a@b.com');
-- BigQuery (MERGE)
MERGE users AS target
USING (SELECT 'a@b.com' AS email) AS source
ON target.email = source.email
WHEN NOT MATCHED THEN INSERT (email) VALUES (source.email);
LIMIT and Pagination
-- MySQL + PostgreSQL + SQLite + BigQuery
SELECT * FROM users LIMIT 10 OFFSET 20;
-- SQL Server
SELECT TOP 10 * FROM users;
-- SQL Server with offset (2012+)
SELECT * FROM users
ORDER BY id
OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY;
String Aggregation
-- MySQL
GROUP_CONCAT(tag ORDER BY tag SEPARATOR ', ')
-- PostgreSQL + BigQuery
STRING_AGG(tag, ', ' ORDER BY tag)
-- SQL Server
STRING_AGG(tag, ', ') WITHIN GROUP (ORDER BY tag)
-- SQLite
GROUP_CONCAT(tag, ', ')
Case-Insensitive Matching
-- MySQL (utf8 collation is case-insensitive by default)
WHERE name LIKE 'mani%'
-- PostgreSQL
WHERE name ILIKE 'mani%'
-- SQLite (case-insensitive for ASCII only)
WHERE name LIKE 'mani%'
-- SQL Server (depends on collation — usually case-insensitive by default)
WHERE name LIKE 'mani%'
-- BigQuery (case-sensitive by default)
WHERE LOWER(name) LIKE 'mani%'
Data Types Quick Reference
| Concept | MySQL | PostgreSQL | SQLite | SQL Server | BigQuery |
|---|---|---|---|---|---|
| Integer | INT | INT | INTEGER | INT | INT64 |
| Large text | TEXT | TEXT | TEXT | NVARCHAR(MAX) | STRING |
| Variable string | VARCHAR(n) | VARCHAR(n) | TEXT | NVARCHAR(n) | STRING |
| Decimal | DECIMAL(p,s) | NUMERIC(p,s) | REAL | DECIMAL(p,s) | NUMERIC |
| Date and time | DATETIME | TIMESTAMP | TEXT | DATETIME | TIMESTAMP |
| UUID | VARCHAR(36) | UUID | TEXT | UNIQUEIDENTIFIER | STRING |
Convert Your SQL Automatically
Do not convert manually — use our free SQL Dialect Converter. Paste your query, choose your source and target database, and get a converted query instantly. Supports MySQL, PostgreSQL, SQLite, SQL Server, and BigQuery. No login. No server. 100% browser-based.
Try the free tool
Use our free browser-based SQL Dialect Converter — no login, nothing sent to servers.
Open SQL Dialect Converter