How to Format SQL INSERT, UPDATE, and DELETE Statements
By Sharon Ben-Moshe · July 13, 2026 · 7 min read
Sharon Ben-Moshe is the founder of sqlfmt, a browser-based SQL formatter and validator with misspelled-keyword suggestions across PostgreSQL, MySQL, SQLite, SQL Server, and BigQuery.
Multi-row INSERT alignment, UPDATE SET clause style, DELETE WHERE formatting, and ON CONFLICT/MERGE upsert syntax across five SQL dialects, with examples.
Quick answer
Format multi-row INSERT statements with one row per line and aligned VALUES, put each column on its own line in an UPDATE's SET clause, and always give WHERE its own line in UPDATE and DELETE statements so the affected rows are unambiguous at a glance. For upsert logic, use each dialect's native syntax — PostgreSQL and SQLite's ON CONFLICT DO UPDATE, MySQL's ON DUPLICATE KEY UPDATE, or SQL Server and BigQuery's MERGE — formatting the UPDATE branch the same way. DML formatting matters more than SELECT formatting because these statements rewrite production data, and a misread WHERE clause is expensive to reverse.