About sql formatter / minifier
Long SQL queries are easier to read and review when each clause starts on its own line with consistent indentation.
What formatting does
- Breaks lines before SELECT, FROM, WHERE, JOIN, GROUP BY and ORDER BY.
- Indents columns, conditions and subqueries.
- Optionally changes the case of keywords.
Minifying
Minified SQL removes extra whitespace for embedding in code. Formatted SQL is better for reviews and debugging.
A worked example
select a,b from users where active=1 and age>18 order by a becomes a query with SELECT, FROM, WHERE and ORDER BY each on its own line and the conditions indented. Readable SQL makes joins and nested subqueries far easier to review.
Style tips
- Use upper case for keywords and lower case for names.
- List columns on separate lines in long queries.
- Alias tables with short names and always qualify column names in joins.
