SQL Cheat Sheet

Searchable, interactive reference of SQL commands, clauses, functions, and patterns with dialect-specific syntax.

About This Tool

The SQL Cheat Sheet is a free, interactive reference for every SQL command you use day-to-day. Instead of hunting through documentation or bookmarked blog posts, you can search, filter by category, and switch between dialect tabs to find exactly the syntax you need in seconds.

Every entry includes a syntax template, a runnable example, and sample output so you can understand what a command does at a glance. Categories cover the full spectrum of SQL: DDL statements like CREATE TABLE and ALTER TABLE; DML operations including SELECT, INSERT, UPDATE, and DELETE; clauses such as WHERE, JOIN, GROUP BY, and ORDER BY; aggregate and scalar functions; subqueries and Common Table Expressions; and modern window functions like ROW_NUMBER, LAG, and running totals.

Because SQL dialects diverge on critical details, the cheat sheet provides dialect-specific tabs for Standard SQL, PostgreSQL, MySQL, and SQLite. Switching tabs updates the example code to show idiomatic syntax for each database — for instance, PostgreSQL's SERIAL and RETURNING clause vs. MySQL's AUTO_INCREMENT and ON DUPLICATE KEY UPDATE.

All content is rendered entirely in your browser. No data is sent to any server, and no login or signup is required. If you are working with raw SQL and need a companion tool, try the SQL Formatter to beautify your queries, or the SQL to Prisma Converter to generate ORM schemas. For JSON output, the JSON to SQL tool can convert JSON data into INSERT statements.

How to Use

  1. Type a keyword into the search bar at the top — for example, JOIN, GROUP BY, or window.
  2. Click a category badge (DDL, DML, Clauses, Functions, Subqueries, Window Functions) to narrow the list.
  3. Select a dialect tab (Standard SQL, PostgreSQL, MySQL, SQLite) to see database-specific syntax where available.
  4. Click any command card to expand it and view the syntax template, example query, and sample output.
  5. Click the Copy button on any syntax or example block to copy it to your clipboard.
  6. Combine search and category filters to quickly find exactly the command you need.
  7. Use Ctrl+F (or Cmd+F) for in-page browser search when you need to scan all expanded entries.

Popular SQL Cheat Sheet Topics

View all SQL cheat sheet examples →

FAQ

Which SQL dialects are covered?

The cheat sheet covers Standard SQL (ANSI), PostgreSQL, MySQL, and SQLite. Each entry shows standard syntax by default. When a command has dialect-specific variations — such as PostgreSQL's RETURNING clause, MySQL's AUTO_INCREMENT, or SQLite's limited ALTER TABLE — switching the dialect tab will display the appropriate syntax.

How do I find a specific SQL command?

Use the search bar to type any keyword — command names (SELECT, INSERT), clauses (WHERE, JOIN), function names (COALESCE, ROW_NUMBER), or concepts (subquery, CTE). You can also filter by category using the badge buttons.

Can I copy the SQL examples?

Yes. Every syntax block and example block has a Copy button in the top-right corner. Click it to copy the code to your clipboard instantly. The button shows a checkmark to confirm the copy succeeded.

Are window functions covered?

Yes. The Window Functions category includes ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, and running aggregate windows (SUM OVER, AVG OVER). Each entry explains the OVER clause, PARTITION BY, ORDER BY, and frame specifications with practical examples.

Is my data safe?

Yes. This is a static reference tool — all content is loaded and rendered entirely in your browser. No data is sent to any server, no cookies are stored, and no login is required.

Does the cheat sheet include examples with sample output?

Yes. Most entries include a Sample Output section showing what the query would return, presented as a formatted text table. This helps you understand the result shape without running the query yourself.

Can I use this for learning SQL?

Absolutely. Each entry is designed to be self-contained: it shows the syntax pattern, a realistic example, and expected output. Categories progress from basic DDL and DML to advanced topics like CTEs and window functions, making it useful as both a quick reference and a learning path.

Related Tools