← Back to all products
$12
SQL Cheatsheet Pack
PostgreSQL, MySQL, and SQLite syntax reference with JOINs, window functions, CTEs, indexing strategies, and query optimization.
MarkdownJSONYAMLSQLPostgreSQL
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 3 files
sql-cheatsheet-pack/
├── LICENSE
├── README.md
└── config.example.yaml
📖 Documentation Preview README excerpt
SQL Cheatsheet Pack
Complete SQL reference covering PostgreSQL, MySQL, and SQLite. JOINs, window functions, CTEs, subqueries, indexing strategies, query optimization, and cross-database syntax differences. Built for professional developers and data engineers.
Who Is This For?
- Backend developers writing application queries and migrations
- Data engineers building ETL pipelines and analytical queries
- Full-stack developers who need SQL reference across multiple databases
- Anyone preparing for SQL-heavy technical interviews
What's Inside
Cheatsheet Files (`cheatsheets/`)
| File | Topics Covered |
|---|---|
01-basic-syntax.md | SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, ALTER TABLE, data types comparison across databases |
02-joins-reference.md | INNER, LEFT, RIGHT, FULL, CROSS, SELF joins with visual diagrams, multiple join conditions, anti-joins |
03-aggregation-grouping.md | GROUP BY, HAVING, aggregate functions (COUNT, SUM, AVG, MIN, MAX), ROLLUP, CUBE, GROUPING SETS |
04-window-functions.md | ROW_NUMBER, RANK, DENSE_RANK, NTILE, LAG, LEAD, FIRST_VALUE, LAST_VALUE, SUM/AVG OVER, frame specs |
05-ctes-subqueries.md | Common Table Expressions, recursive CTEs, correlated subqueries, EXISTS, IN vs JOIN, materialized CTEs |
06-indexing-strategies.md | B-tree, hash, GIN, GiST indexes, composite indexes, partial indexes, covering indexes, EXPLAIN analysis |
07-query-optimization.md | Reading EXPLAIN plans, common anti-patterns, N+1 queries, query rewriting, statistics, vacuuming |
08-database-differences.md | PostgreSQL vs MySQL vs SQLite syntax matrix, feature comparison, type mapping, migration considerations |
Example Files (`examples/`)
| File | Description |
|---|---|
create_schema.sql | Complete sample database schema with tables, indexes, constraints |
window_functions.sql | 15+ window function examples with sample data and results |
recursive_ctes.sql | Recursive CTE patterns: hierarchies, sequences, graph traversal |
optimization_before_after.sql | Slow queries rewritten for performance with EXPLAIN comparison |
Quick Reference (`cheatsheet.html`)
Self-contained HTML file with the essential SQL reference tables. Open in any browser or print.
How to Use
1. Unzip the archive
2. Browse cheatsheets/ for topic-specific reference
3. Run example .sql files against your database
4. Open cheatsheet.html for a printable quick-reference
5. The sample schema uses generic naming -- adapt table/column names to your project
Format Notes
- Default syntax is PostgreSQL with MySQL/SQLite differences noted inline
- Where syntax differs, a comparison table shows all three
- Example queries use a sample e-commerce schema (users, orders, products)
- All examples use
example.comdomains and placeholder data
Version History
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2026-06 | Initial release: 8 cheatsheets, 4 example files, HTML reference |
... continues with setup instructions, usage examples, and more.
📄 Code Sample .sql preview
examples/create_schema.sql
-- ============================================================
-- Sample E-Commerce Schema
-- Database: PostgreSQL (compatible with most changes for MySQL/SQLite)
-- ============================================================
-- Users
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
status VARCHAR(20) DEFAULT 'active' CHECK (status IN ('active', 'inactive', 'banned')),
tier VARCHAR(20) DEFAULT 'bronze' CHECK (tier IN ('bronze', 'silver', 'gold', 'platinum')),
city VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Categories (self-referencing for tree structure)
CREATE TABLE categories (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
parent_id INTEGER REFERENCES categories(id),
active BOOLEAN DEFAULT TRUE
);
-- Products
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
category_id INTEGER REFERENCES categories(id),
price DECIMAL(10, 2) NOT NULL CHECK (price >= 0),
stock INTEGER DEFAULT 0 CHECK (stock >= 0),
description TEXT,
active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Orders
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
status VARCHAR(20) DEFAULT 'pending'
CHECK (status IN ('pending', 'processing', 'shipped', 'delivered', 'cancelled')),
total DECIMAL(10, 2) NOT NULL DEFAULT 0,
shipping_city VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
shipped_at TIMESTAMP,
delivered_at TIMESTAMP
);
# ... 90 more lines ...