How I format SQL before reviewing a query
· 2 min read
SQL is easier to review when clauses and joins are on separate lines instead of one long string.
The SQL Prettify tool helps me inspect the input and output without writing a one-off script first.
The simple idea
SQL is easier to review when clauses and joins are on separate lines instead of one long string.
I use it to answer one focused question at a time, then I review the result before using it anywhere important.
Step 1: Paste the SQL query
Paste the SQL query.
Step 2: Format it with readable indentation
Format it with readable indentation.
Step 3: Review selected columns
Review selected columns.
Step 4: Check joins and join conditions
Check joins and join conditions.
Step 5: Check WHERE filters before running updates or deletes
Check WHERE filters before running updates or deletes.
Step 6: Review ORDER BY and LIMIT
Review ORDER BY and LIMIT.
Step 7: Formatting does not make a query safe; it only makes it easier to inspect
Formatting does not make a query safe; it only makes it easier to inspect.
My checklist
Before I trust the result, I check:
- Paste the SQL query.
- Format it with readable indentation.
- Review selected columns.
- Check joins and join conditions.
- Check WHERE filters before running updates or deletes.
- Review ORDER BY and LIMIT.
- Formatting does not make a query safe; it only makes it easier to inspect.
The tool makes the mechanical part faster. The decision still belongs to me: is this result correct, safe, and appropriate for the real task?
Comments
Comments are welcome — please read the comment policy first. Powered by giscus and GitHub Discussions.