Skip to main content

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

CREATE TABLE Statement
 
Was this helpful?

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

  1. Choose your SQL Dialect. This drives every dialect-specific decision below.
  2. Enter a Table Name.
  3. Describe your Columns, one per line (see the syntax below).
  4. Optionally add Indexes, one per line.
  5. 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) or decimal(10,2).
  • flags (any order, space-separated):
    • pk — mark as PRIMARY KEY
    • ai — auto-increment (rendered per dialect: AUTO_INCREMENT, SERIAL/BIGSERIAL, AUTOINCREMENT, or IDENTITY(1,1))
    • notnull — NOT NULL
    • unique — UNIQUE
    • default=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 unique for 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. varchar becomes TEXT in SQLite and NVARCHAR in SQL Server; json becomes JSONB in PostgreSQL; boolean becomes BIT in SQL Server.
  • Auto-increment — MySQL AUTO_INCREMENT, PostgreSQL SERIAL/BIGSERIAL, SQLite inline INTEGER PRIMARY KEY AUTOINCREMENT, SQL Server IDENTITY(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.

sqlddlcreate tabledatabaseschemamysqlpostgresql

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.