跳到主要内容

SQL 格式化

UpBox优盒工具箱,免费在线 SQL 格式化工具,把挤成一行的查询语句自动按 SELECT / FROM / WHERE 换行缩进,统一关键字大小写,保留字符串与注释,支持复制与下载 .sql。

无需注册 · 数据不上传No sign-up · nothing uploaded

原始 SQLRaw SQL

输出行数0
关键字0
字符数0

格式化结果Formatted SQL

粘贴 SQL 后自动格式化

面向常见 SELECT / INSERT / UPDATE / DELETE 语句;存储过程等复杂结构请格式化后自行复核

本工具所有运算在本地浏览器完成,你的文件、文本不会上传到服务器

工具介绍

从日志、接口或聊天里复制出来的 SQL 往往挤成一行,格式化后每个子句独立成行,字段列表按逗号拆开,WHERE 里的 AND / OR 也会换行。 SQL copied from logs, APIs or chat often arrives on one line; formatting gives each clause its own line, splits the field list on commas and breaks AND / OR in WHERE.

字符串、反引号标识符与 -- / /* */ 注释原样保留;关键字大小写可一键统一,输出行数、关键字数与字符数会实时统计。 Strings, quoted identifiers and -- or block comments are preserved as-is; keyword case can be normalized, with line, keyword and character counts updated live.

  • 子句换行Clause line breaks
  • 字段逗号拆分Comma-split fields
  • AND / OR 缩进Indented AND / OR
  • 关键字大写Keyword uppercase
  • 注释与字符串保留Preserves strings and comments

使用说明

  1. 粘贴需要整理的 SQL。Paste the SQL you want to clean up.
  2. 右侧自动生成格式化结果。The formatted SQL appears on the right.
  3. 按需取消关键字大写。Turn keyword uppercase off if you prefer.
  4. 复制结果或下载 .sql。Copy the result or download the .sql file.

常见问题

会改变 SQL 语义吗?Does it change SQL semantics?
只调整空白与关键字大小写,不增删字符;字符串与注释内容不会被大写。It only adjusts whitespace and keyword case, never adds or removes tokens; strings and comments are untouched.
支持子查询吗?Are subqueries supported?
支持常见括号子查询,会额外缩进一层;多层嵌套建议检查后再执行。Common parenthesized subqueries are indented one level; review deeply nested ones before running.
存储过程能格式化吗?Can it format stored procedures?
BEGIN / END 等过程结构只做基础整理,可能不符合你的排版习惯,请手动复核。Procedural BEGIN / END blocks get only basic treatment and may not match your style — review them manually.
会上传 SQL 吗?Is the SQL uploaded?
不会,格式化完全在浏览器本地完成。No, formatting runs entirely in the browser.
广告位

此处为广告位,可放置你的推广素材

支持图片、文字或 HTML 代码,替换本区块内容即可投放

浏览其他分类