Align SQL Column Definitions
Align SQL CREATE TABLE column definitions so that types, constraints, and defaults form clean columns.
Detailed Explanation
Formatting SQL Column Definitions
SQL CREATE TABLE statements with many columns often become hard to read when the types and constraints are not aligned. Aligning these definitions makes the schema easier to review during code reviews and database design discussions.
Before
id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(320) NOT NULL UNIQUE,
age INTEGER,
salary DECIMAL(10,2) DEFAULT 0.00,
is_active BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
After (aligned on spaces)
id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(320) NOT NULL UNIQUE,
age INTEGER,
salary DECIMAL(10,2) DEFAULT 0.00,
is_active BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
Steps
- Paste the column definitions (one per line, without the
CREATE TABLEwrapper). - Select Spaces (2+) as the input delimiter.
- Set the output delimiter to Spaces.
- Left-align all columns.
Multi-Step Alignment
For SQL with many parts per line (name, type, nullability, default, constraint), you may need to do two passes:
- First align names and types.
- Then manually adjust constraints.
Alternatively, use the Custom delimiter with a regex-safe pattern to get finer control over the split points.
Complements the SQL Formatter
This column aligner focuses on the visual layout of column definitions. For full SQL formatting with keyword capitalization, indentation, and clause rewriting, use a dedicated SQL formatter alongside this tool.
Use Case
A database designer preparing a migration script wants to format a long CREATE TABLE statement so that every column's type and constraints are visually aligned.