Developer Tools

MySQL CREATE TABLE Generator

Type a table the way you would sketch it on paper, one short line per column, and get a correct MySQL CREATE TABLE statement. Column types are guessed from common naming conventions: id becomes an auto-increment BIGINT key, team_id a foreign key to teams, created_at a DATETIME, is_verified a boolean and price a DECIMAL. Add types, defaults and flags where you need something else.

  • Runs in your browser
  • No sign-up
  • Free to use
Start from an example

name [type] [?] [unique] [= default] [-> table]. Types are guessed from names: id, *_id, *_at, is_*, email, price… Keywords: timestamps, soft deletes, index(a, b), unique(a, b).

Options

    How to use MySQL CREATE TABLE Generator

    1. Enter the table name.
    2. Write one column per line, e.g. “email unique” or “bio text?”.
    3. Add timestamps, soft deletes or indexes as keywords.
    4. Copy the CREATE TABLE statement.

    MySQL CREATE TABLE Generator features

    Convention-based types

    id, *_id, *_at, *_on, is_*, email, url, price, count and more.

    Short syntax

    name type? unique = default -> table on one line.

    Foreign keys

    *_id columns reference the plural table with matching types.

    Keywords

    timestamps, soft deletes, index(a, b), unique(a, b).

    UUID keys

    Optional CHAR(36) keys with DEFAULT (UUID()).

    Explained

    The notes list every guessed type so you can check it.

    When to use MySQL CREATE TABLE Generator

    • Sketching a table during planning and getting real SQL immediately.
    • Writing migrations faster than with a GUI.
    • Turning a column list from a ticket into a table.
    • Learning MySQL conventions used by frameworks such as Laravel.

    MySQL CREATE TABLE Generator FAQ

    What does the notation look like?

    One column per line: the name, optionally a type such as string(120), enum(a, b) or decimal(10,2), a ? for nullable, unique, = default and -> table for a foreign key.

    How are types guessed?

    From names: id is the primary key, *_id a foreign key, *_at a DATETIME, *_on a DATE, is_*/has_* a boolean, email a VARCHAR(255), price/amount/total a DECIMAL(10,2) and description/body a TEXT.

    Where does team_id point?

    To teams.id, the plural of the name before _id. Write -> other_table to choose another table.

    What does timestamps add?

    created_at and updated_at, both NOT NULL with DEFAULT CURRENT_TIMESTAMP, and updated_at with ON UPDATE CURRENT_TIMESTAMP.

    How is this different from the MySQL Table Generator?

    That tool is a visual designer with a row per column; this one turns a few lines of text into SQL, which is faster when you know what you want.

    Is anything uploaded?

    No. Everything is generated in your browser.

    Tables from conventions

    Most tables follow the same patterns. Every table has an id, relations are columns ending in _id, points in time end in _at, flags start with is_ or has_, and money columns are called price, amount or total. Frameworks such as Rails and Laravel build on these conventions, and this generator uses them to fill in types you do not write explicitly.

    The notation is deliberately short. email unique gives a VARCHAR(255) NOT NULL UNIQUE column; bio text? a nullable TEXT; plan enum(free, pro) = free an ENUM with a default; referred_by_id? -> customers a nullable foreign key to customers. Columns are NOT NULL unless marked with a question mark, which is the safer default.

    Foreign keys get matching types automatically. Because id columns are BIGINT UNSIGNED, columns ending in _id are BIGINT UNSIGNED as well, which MySQL requires for the constraint to be created. Required relations cascade on delete and optional ones are set to NULL, and you can override that per column.

    Keywords add common structures in one line: timestamps adds created_at and updated_at with MySQL maintaining updated_at, soft deletes adds an indexed deleted_at, and index(a, b) or unique(a, b) add composite indexes. The output uses InnoDB and utf8mb4 with the collation you choose.

    Because guessing can be wrong, the notes list every column whose type was inferred from its name. If one is not what you want, add a type after the name and the guess is replaced.

    Other useful tools