SQL 치트시트
SQL 문법, 조인, 함수, 데이터 타입 빠른 참조.
동작 원리
SQL evaluates logically as FROM/JOIN -> WHERE -> GROUP BY -> HAVING -> SELECT/WINDOW -> DISTINCT -> ORDER BY -> LIMIT, even though `SELECT` is written first.
서바이벌 키트
가장 먼저 배워야 할 몇 가지 명령어입니다.
42개 명령어
Select, Filter & Pagination
Filter predicates safely, avoid NULL traps, sort, and paginate efficiently.
- 기본
Filter rows, sort deterministically, and cap returned rows
SELECT <cols> FROM <table> WHERE <cond> ORDER BY <col> DESC LIMIT <n>;명령어 만들기
SELECT <cols> FROM <table> WHERE <cond> ORDER BY <col> DESC LIMIT <n>;값은 입력한 그대로 삽입됩니다. 공백이나 특수 문자가 포함된 경우 직접 따옴표로 감싸 주세요.
사용 시점
Adding a tie-breaker column to `ORDER BY` guarantees repeatable pagination order.
예제
SELECT id, email, created_at FROM users WHERE status = 'active' ORDER BY created_at DESC, id DESC LIMIT 25;
Joins & Set Operations
Combine related tables cleanly and find orphan or unmatched rows.
Aggregation, CTEs & Window Functions
Group metrics, stage readable queries with CTEs, and rank without collapsing rows.
Insert, Upsert, Update & Delete
Write idempotent mutations safely inside transactions without locking accidents.
Schema, Constraints, JSON & Performance
Design tables, composite indexes, JSON queries, and inspect EXPLAIN plans.