跳转到主要内容
kitlocal.dev

SQL 速查表

本地运行

100% 在你的浏览器中处理。输入和输出绝不会离开你的设备。

SQL 语法、连接、函数和数据类型速查。

工作原理

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 工具中试用