Cheat Sheet
The commands you keep forgetting, with a one-line description and a real example you can copy - 384 across 26 tools. Pick a tool in the sidebar, or search across all of them.
SQL
The core queries for reading and changing relational data.| Command | What it does | Example |
|---|---|---|
SELECT | Read columns from a table. | SELECT id, name FROM users; |
WHERE | Filter rows by a condition. | SELECT * FROM users WHERE age >= 18; |
ORDER BY | Sort the results. | SELECT * FROM users ORDER BY created_at DESC; |
LIMIT | Return at most N rows. | SELECT * FROM users LIMIT 10; |
INSERT | Add a new row. | INSERT INTO users (name, email) VALUES ('Ana', '[email protected]'); |
UPDATE | Change existing rows (always with WHERE). | UPDATE users SET active = true WHERE id = 5; |
DELETE | Remove rows (always with WHERE). | DELETE FROM users WHERE id = 5; |
INNER JOIN | Combine rows that match in both tables. | SELECT * FROM orders o JOIN users u ON u.id = o.user_id; |
LEFT JOIN | Keep all left rows, match where possible. | SELECT u.name, o.id FROM users u LEFT JOIN orders o ON o.user_id = u.id; |
GROUP BY | Collapse rows into groups for aggregates. | SELECT user_id, COUNT(*) FROM orders GROUP BY user_id; |
HAVING | Filter groups after aggregation. | SELECT user_id, COUNT(*) FROM orders GROUP BY user_id HAVING COUNT(*) > 3; |
COUNT / AVG | Aggregate over rows. | SELECT AVG(total) FROM orders; |
DISTINCT | Return only unique values. | SELECT DISTINCT country FROM users; |
LIKE | Match a text pattern (% = any run). | SELECT * FROM users WHERE email LIKE '%@gmail.com'; |
CREATE TABLE | Define a new table. | CREATE TABLE tags (id SERIAL PRIMARY KEY, name TEXT NOT NULL); |
ALTER TABLE | Add or change a column. | ALTER TABLE users ADD COLUMN phone TEXT; |
CREATE INDEX | Speed up lookups on a column. | CREATE INDEX idx_users_email ON users (email); |