SQL Cheat Sheet Index
Browse through categorized templates covering standard SQL syntax. Copy snippets, check dialect optimizations, or study CTE and transaction structures.
SELECT All Columns
Retrieves all available fields and rows from a target database table.
SELECT Specific Columns
Retrieves only specified projections from the table, minimizing network load.
Filter with WHERE
Filters row returns matching a specific logical condition.
Create Table
Establishes a new database relation with structured fields and constraint checks.
Add Column
Mutates an existing schema structure to append a new nullable data field.
Drop Table
Destroys an active database table along with all its recorded indexes and rows.
Insert Record
Appends a new structured row values entry into a target relation.
Update Record
Modifies active fields in records matching a filtering index condition. WARNING: Always use WHERE!
Delete Record
Safely removes row objects matching criteria from the relation. WARNING: Always use WHERE!
INNER JOIN
Combines two tables, returning rows only where the join key matches in both tables.
LEFT OUTER JOIN
Returns all rows from the left table, and matching rows from the right table. Fills NULLs if unmatched.
GROUP BY & COUNT
Aggregates matching records together and performs arithmetic counting calculations.
Filter Aggregates with HAVING
Filters aggregated grouping scopes (WHERE executes before aggregations, HAVING executes after).
Common Table Expressions (CTE)
Encapsulates complex intermediate subqueries into readable sequential scopes.
Window Function: ROW_NUMBER()
Assigns ranks sequentially to partitioned subsets without collapsing matching rows.
Create Standard Index
Constructs a B-Tree search index to accelerate lookups on high-selectivity columns.
Create Composite Index
Establishes a single multi-column index. Ideal for composite equality filter parameters.
Transaction Block (ACID)
Ensures relational execution sequences either fully complete or safely rollback together.
