SQL formatting guides
Practical guides on writing SQL that people can read, review and maintain: style conventions, complex queries, team workflows and dialect differences. Every formatted example on these pages was produced by the SQL Format engine itself.
- SQL style guide Naming, keyword case, indentation, aliases, explicit JOINs, comments and CTEs: a pragmatic set of conventions a team can actually keep.
- How to format complex SQL queries CTEs, nested subqueries, CASE, window functions and UNION: how to lay out queries that span a whole screen or more.
- Leading vs trailing commas in SQL An in-depth comparison of both comma styles: diffs, commenting out columns, scanning and the errors each style prevents.
- Formatting SQL for code review and version control How consistent formatting keeps diffs clean, how to roll out a team standard, and how to review SQL in pull requests.
- Common SQL readability mistakes Implicit joins, SELECT *, one-letter aliases, mixed AND/OR and more: frequent habits that make SQL hard to read, and how to fix them.
- Formatting PostgreSQL queries and PL/pgSQL Casts, parameters, RETURNING, ON CONFLICT and dollar-quoted PL/pgSQL bodies: what the formatter does with PostgreSQL syntax.
- SQL dialect differences that affect formatting Identifier quoting, LIMIT vs FETCH FIRST vs TOP, batch separators and procedural blocks across the major databases.
- SQL formatting checklist before deploying a migration A short checklist to run before a schema or data migration goes to review and production.