Zero Signup ToolsFree browser tools

Developer Tools

SQL CREATE TABLE Builder

Build a CREATE TABLE statement in your browser. MySQL, PostgreSQL, SQLite, and SQL Server, with columns, constraints, indexes, and foreign keys.

SQL CREATE TABLE builder

Table

Dialect

Overrides per-column PRIMARY KEY flags when filled in.

SQL output

308 characters5 columns1 index0 foreign keys

Columns

Add columns and set the type, nullability, default, and key flags. Drag-free reorder with the arrow buttons.

Column 1
Name
Type
Length (n/a)
Scale (n/a)
Default kind
Default value
Column 2
Name
Type
Length
Scale (n/a)
Default kind
Default value
Column 3
Name
Type
Length
Scale (n/a)
Default kind
Default value
Column 4
Name
Type
Length (n/a)
Scale (n/a)
Default kind
Default value
Column 5
Name
Type
Length (n/a)
Scale (n/a)
Default kind
Default value

Indexes

Emits a CREATE INDEX (or CREATE UNIQUE INDEX) statement per row.

Index 1

Foreign keys

Adds a CONSTRAINT FOREIGN KEY line inside the CREATE TABLE body.

No foreign keys yet. Add one to reference another table.

Notes by dialect

  • MySQL: AUTO_INCREMENT requires INTEGER family columns. BOOLEAN renders as TINYINT(1). JSON and DATETIME are native.
  • PostgreSQL: marking an INT/BIGINT/SMALLINT with Auto increment switches the type to SERIAL / BIGSERIAL / SMALLSERIAL for backwards-compatible DDL. JSON stores as JSONB.
  • SQLite: Type affinities collapse to INTEGER, REAL, TEXT, NUMERIC, and BLOB. AUTOINCREMENT is only valid on INTEGER PRIMARY KEY.
  • SQL Server: IF NOT EXISTS is emulated with IF OBJECT_ID(...). BOOLEAN renders as BIT, UUID as UNIQUEIDENTIFIER, JSON as NVARCHAR(MAX).

Output is generated locally and never sent to a server. Copy the SQL into your favorite database client to run it.

How to use

  1. Pick a dialect: MySQL, PostgreSQL, SQLite, or SQL Server. Types, identifier quoting, and auto-increment syntax change to match the dialect you choose.
  2. Type a table name and (optionally) a schema. Toggle IF NOT EXISTS, DROP TABLE first, identifier quoting, and trailing semicolons as needed for your migration style.
  3. Add each column with a name and type. Set length and scale for parameterized types (VARCHAR, DECIMAL). Mark columns NOT NULL, primary key, unique, or auto-increment.
  4. Pick a default kind per column: no default, NULL, a literal value (quoted as a string for text and dates), or a raw expression like CURRENT_TIMESTAMP that is emitted verbatim.
  5. For a multi-column key, fill in the composite primary key field with a comma-separated column list. It overrides the per-column primary key flags.
  6. Add CREATE INDEX rows for non-key columns you want to query on, and FOREIGN KEY rows for relationships with ON DELETE and ON UPDATE actions.
  7. Click Copy SQL to copy the generated CREATE TABLE statement (plus any CREATE INDEX statements) to your clipboard, then paste it into your database client.

About this tool

SQL CREATE TABLE Builder turns a column roster into a ready-to-run CREATE TABLE statement for MySQL, PostgreSQL, SQLite, or SQL Server. Each dialect emits its own identifier quoting (backticks for MySQL, double quotes for PostgreSQL and SQLite, square brackets for SQL Server), its own auto-increment syntax (AUTO_INCREMENT, SERIAL/BIGSERIAL, AUTOINCREMENT, or IDENTITY), its own canonical types (TINYINT(1) vs BIT vs BOOLEAN, DATETIME vs TIMESTAMP, JSONB vs JSON vs TEXT vs NVARCHAR(MAX)), and the right shape of IF NOT EXISTS (a plain clause everywhere except SQL Server, which gets an IF OBJECT_ID guard). Define each column with a name, a type (INT, BIGINT, SMALLINT, DECIMAL with precision and scale, FLOAT, DOUBLE, BOOLEAN, VARCHAR, CHAR, TEXT, DATE, TIME, TIMESTAMP, UUID, JSON, or BLOB), a NOT NULL flag, primary and unique flags, an auto-increment flag (integer columns only), and a default expression or literal. Choose a composite primary key when more than one column makes up the key. Add as many indexes as you need, each one emitted as a CREATE INDEX or CREATE UNIQUE INDEX statement after the table. Add foreign keys with ON DELETE and ON UPDATE actions (CASCADE, RESTRICT, SET NULL, SET DEFAULT, or NO ACTION); they render as named CONSTRAINT FOREIGN KEY lines inside the table body. Toggle DROP TABLE first when you want to recreate cleanly, toggle trailing semicolons for files that expect them, and toggle identifier quoting when reserved words or camelCase column names need protection. The tool flags duplicate column names, missing table or column names, and dialect-specific surprises (such as SQLite only allowing AUTOINCREMENT on INTEGER PRIMARY KEY) before it emits anything. Useful for prototyping schemas, writing migration scripts, sharing a quick DDL snippet in a code review, teaching SQL syntax across dialects, and seeding a new repository's first migration file. Everything is built in your browser; no schema, column names, or default values leave the page.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools