Skip to main content
Albero Academy

Best Practices

Write SQL that is correct, readable and safe.

Applied SQL8 min

Good SQL is correct, readable and safe. A handful of habits separate professional queries from fragile ones.

Core habits

  • List columns — avoid SELECT * in production; name what you need.
  • Always WHERE on writes — preview UPDATE/DELETE with a SELECT first.
  • Parameterise input — never build SQL by string concatenation (SQL injection).
  • Format for readability — uppercase keywords, one clause per line, meaningful aliases.
  • Use transactions for multi-step changes; index thoughtfully.
  • Let the database do the work — filter, join and aggregate in SQL, not in application code.

The security non-negotiable

Key takeaways

  1. 01Name columns instead of SELECT *; always WHERE on UPDATE/DELETE (preview with SELECT).
  2. 02Never build SQL by string concatenation — use parameterised queries to stop injection.
  3. 03Format for readability: uppercase keywords, one clause per line, clear aliases.
  4. 04Use transactions for multi-step changes and let the database do the filtering/aggregation.

Finished this chapter?

Mark it complete to track your progress through SQL.