How to Format SQL CREATE TABLE Statements
By Sharon Ben-Moshe · August 8, 2026 · 2 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.
A CREATE TABLE statement is the schema every future query has to live with — formatted well, it doubles as documentation. Here's a consistent, readable way to lay out columns, constraints, and keys.
Quick answer
A readable CREATE TABLE statement puts one column per line, states NOT NULL and DEFAULT inline with the column, and places multi-column constraints — PRIMARY KEY, FOREIGN KEY, UNIQUE — on their own named lines after the columns rather than mixed in with them.