跳至主要內容
kitlocal.dev

SQL 速查表

本機執行

100% 在你的瀏覽器中處理。輸入與輸出絕不會離開你的裝置。

SQL 語法、JOIN、函式與資料型別的快速參考。

運作原理

SQL evaluates logically as FROM/JOIN -> WHERE -> GROUP BY -> HAVING -> SELECT/WINDOW -> DISTINCT -> ORDER BY -> LIMIT, even though `SELECT` is written first.

生存指南

最先需要掌握的少數核心指令。

42 個指令

鍵盤快捷鍵/聚焦搜尋列JK移動選取項目C複製選取的指令F將選取項目加入或移除書籤Esc清除搜尋

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.

在 KitLocal 工具中試用