SQL cheat sheets
One page per engine with the SQL you type every day: selects, joins, aggregation, DML, DDL, indexes, functions and NULL handling. Each snippet is written for its own engine rather than copied between them, and each sheet prints as a two-column reference card.
SQL Server cheat sheet
SELECT TOP (10) * FROM dbo.customers ORDER BY last_name;
SELECT with TOP, joins, IDENTITY columns, MERGE, OFFSET/FETCH paging, string and date functions, plus the quirks that trip people up.
Open the SQL Server sheetPostgreSQL cheat sheet
SELECT * FROM customers ORDER BY last_name LIMIT 10;
LIMIT and OFFSET, joins, RETURNING, ON CONFLICT upserts, ::casts, FILTER, date_trunc, string_agg and the quoting rules that bite everyone once.
Open the PostgreSQL sheetMySQL cheat sheet
SELECT * FROM customers ORDER BY last_name LIMIT 10;
LIMIT, joins, AUTO_INCREMENT, INSERT IGNORE, ON DUPLICATE KEY UPDATE, GROUP_CONCAT, date functions, backticks and the utf8mb4 gotchas.
Open the MySQL sheetSQLite cheat sheet
SELECT * FROM customers ORDER BY last_name LIMIT 10;
LIMIT, joins, INTEGER PRIMARY KEY, INSERT OR REPLACE, ON CONFLICT upserts, date functions on text columns and the type rules that surprise people.
Open the SQLite sheetOracle cheat sheet
SELECT * FROM customers ORDER BY last_name FETCH FIRST 10 ROWS ONLY;
FETCH FIRST, ROWNUM, dual, sequences, LISTAGG, TO_CHAR and TO_DATE, NVL, MERGE, and the empty string that is really NULL.
Open the Oracle sheetSame task, five dialects
Six things every sheet covers, side by side. Each cell is copied from that engine's own sheet, so it is the same engine-checked SQL you get on the full page.
| タスク | SQL Server | PostgreSQL | MySQL | SQLite | Oracle |
|---|---|---|---|---|---|
| First 10 rows, ordered |
|
|
|
|
|
| Page 3, 10 rows per page |
|
|
|
|
(12c+)
|
| Upsert |
with MERGE
|
with ON CONFLICT
|
with ON DUPLICATE KEY UPDATE (row alias: 8.0.19+)
|
with ON CONFLICT
|
with MERGE
|
| Substitute a default for NULL |
|
|
|
|
|
| Current date and time |
|
|
|
|
|
| Create a table with a generated key |
|
|
|
|
|
SQL cheat sheet FAQ
What is in each SQL cheat sheet?
Grouped, copy-pasteable snippets: SELECT basics, joins, filtering, aggregation, INSERT/UPDATE/DELETE, CREATE/ALTER/DROP, indexes, string functions, date functions, NULL handling and paging. Each sheet also lists the engine's quirks: the places where its dialect differs from the others and catches people moving between them.
Which database engines are covered?
SQL Server (T-SQL), PostgreSQL, MySQL (with notes where MariaDB differs), SQLite and Oracle. Each sheet is written against that engine's syntax: TOP versus LIMIT versus FETCH FIRST, backticks versus brackets versus double quotes, and so on.
Can I print a cheat sheet?
Yes. Each sheet has its own print stylesheet: the site navigation, FAQ and calls to action drop out, and the snippet tables print in two compact columns. Print or save as PDF from your browser.
Is this free?
Yes, with no sign-up. The SQLly desktop app connects to all five engines if you want to run the snippets against your own database.
Run these against your own database
SQLly is a native SQL workbench for macOS, Windows and Linux. It connects to all five engines on these sheets, and its IntelliSense completes from your real schema.