全球免费使用

SQL 格式化

缩进 SQL 语句,不连接也不执行任何数据库。

此工具会将文件或输入上传到我们的隔离处理器。任务完成后会删除工作文件。请勿提交敏感或机密材料。

输入

提示:按 Ctrl + Enter 运行

你的结果

结果将显示在这里。

下方的详细帮助目前仅提供英文版。

关于此工具

Queries copied from logs, ORMs or one-line scripts are hard to read and review. This formatter re-indents SQL statements, puts major clauses (SELECT, FROM, WHERE, JOIN, ORDER BY) on their own lines and uppercases keywords, making the structure obvious before you debug or share a query.

It only reformats text. It does not connect to any database, check that tables exist, or execute anything.

使用方法

  1. Paste one or more SQL statements.
  2. Confirm the server-side processing and run the formatter.
  3. Copy the formatted SQL back into your editor or ticket.
  4. Review it; formatting does not validate syntax for your specific database.

计算原理

The text is processed by the sqlparse library with reindent and uppercase keywords. Comments and literals are preserved.

计算示例

The one-line query "select id, name from users where active = 1 order by name;" becomes SELECT id, name on the first lines, then FROM users, WHERE active = 1 and ORDER BY name on separate lines, with keywords in capitals.

局限性

  • Up to 50,000 characters.
  • Formatting only; no validation or execution.
  • Style options (indent width, keyword case) are fixed.

最后更新:

常见问题

Which SQL dialects are supported?

It formats common SQL used by PostgreSQL, MySQL, SQLite and SQL Server. Very dialect-specific syntax may be formatted imperfectly.

Does it fix syntax errors?

No. It reformats what you give it; invalid SQL stays invalid.

Is my query stored?

It is processed in a temporary job on the server and not kept after the request.

故障排除

The result looks odd around a vendor-specific clause.

The parser may not recognize it. Format that part by hand.

Nothing happens when I run it.

Tick the processing confirmation box; server tools need it.

Sensitive data is in the query.

Replace real values with placeholders before formatting queries that contain personal data.

隐私 & 免费使用

我的输入会被保存吗?

此工具会将文件或输入上传到我们的隔离处理器。任务完成后会删除工作文件。请勿提交敏感或机密材料。

这个工具免费吗?

是的。无需注册或付费。

服务器处理

推荐下一步