SQL CREATE TABLE Generator
Generate a CREATE TABLE SQL statement from simple column definitions. Supports MySQL, PostgreSQL, SQLite, and SQL Server dialects with per-dialect type mapping, auto-increment, primary/foreign keys, and indexes.
Input
One column per line: name type[(length)] then optional flags. Flags: pk, ai, notnull, unique, default=VALUE, fk=table(col). Types: integer, bigint, smallint, varchar, text, boolean, date, datetime, timestamp, json, decimal, float, double, uuid, blob.
One index per line: [unique] [index_name:] col1, col2. Example: 'unique uq_email: email' or 'created_at'.
Output
Guides
Build a ready-to-run CREATE TABLE statement by describing your columns in plain text — no SQL boilerplate to remember. Pick a dialect (MySQL, PostgreSQL, SQLite, or SQL Server) and the generator handles the identifier quoting, type mapping, primary/foreign keys, auto-increment syntax, and indexes for that engine. Everything runs in your browser; nothing you type is sent anywhere.
How to use it
- Choose your SQL Dialect. This drives every dialect-specific decision below.
- Enter a Table Name.
- Describe your Columns, one per line (see the syntax below).
- Optionally add Indexes, one per line.
- Toggle Add IF NOT EXISTS and Pretty-print output to taste.
The generated SQL updates as you type, and you can copy or download it as a .sql file.
Column syntax
Each line defines one column:
name type[(length)] [flags...]
- name — the column name (first token).
- type — one of:
integer,bigint,smallint,varchar,text,boolean,date,datetime,timestamp,json,decimal,float,double,uuid,blob. Add a length/precision in parentheses, e.g.varchar(255)ordecimal(10,2). - flags (any order, space-separated):
pk— mark as PRIMARY KEYai— auto-increment (rendered per dialect:AUTO_INCREMENT,SERIAL/BIGSERIAL,AUTOINCREMENT, orIDENTITY(1,1))notnull— NOT NULLunique— UNIQUEdefault=VALUE— a DEFAULT clause; the value is inserted verbatim (default=0,default=CURRENT_TIMESTAMP,default='active')fk=table(col)— a FOREIGN KEY referencing another table's column
Example:
id bigint pk ai notnull
name varchar(255) notnull
email varchar(255) notnull unique
author_id bigint fk=users(id)
created_at timestamp notnull default=CURRENT_TIMESTAMP
Lines that are blank or start with -- are ignored, so you can leave comments.
Index syntax
Each line defines one index:
[unique] [index_name:] col1, col2
- Prefix with
uniquefor a unique index. - Add
name:before the columns to name the index; otherwise a name is derived from the table and columns. - List one or more columns separated by commas.
For MySQL, indexes are emitted inline inside the CREATE TABLE; for the other dialects they become separate CREATE INDEX statements.
Dialect differences
The generator adapts to each engine automatically, including:
- Identifier quoting — backticks for MySQL,
[brackets]for SQL Server, and"double quotes"elsewhere. - Type mapping — e.g.
varcharbecomesTEXTin SQLite andNVARCHARin SQL Server;jsonbecomesJSONBin PostgreSQL;booleanbecomesBITin SQL Server. - Auto-increment — MySQL
AUTO_INCREMENT, PostgreSQLSERIAL/BIGSERIAL, SQLite inlineINTEGER PRIMARY KEY AUTOINCREMENT, SQL ServerIDENTITY(1,1).
Is my data uploaded anywhere?
No. The tool runs entirely in your browser — your schema never leaves your machine.
Can I generate DDL for a dialect not listed?
The four supported dialects cover MySQL, PostgreSQL, SQLite, and SQL Server. Output for a similar engine (e.g. MariaDB) is usually compatible with the MySQL setting.