SQL CREATE TABLE Generator

Design a table column by column — types, primary key, NOT NULL, UNIQUE, auto-increment and defaults — and get the correct CREATE TABLE syntax for your database. Or infer the columns from a CSV or JSON sample.

Runs in your browserUpdated
Dialect

Columns

NameTypeLengthPKNNUQAIDefault
Infer columns from CSV, Excel cells or JSON

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the CREATE TABLE Generator

  1. Enter the table name and pick your database dialect.
  2. Add columns: name, type and length, then tick PK, NN (NOT NULL), UQ (UNIQUE) or AI (auto-increment) and set a default if needed.
  3. Optionally paste a CSV or JSON sample under Infer columns to create the columns automatically.
  4. Copy the generated CREATE TABLE statement or download it as .sql.

What is a CREATE TABLE statement?

CREATE TABLE is the SQL data definition (DDL) statement that creates a table: its name, each column with a data type, and constraints such as primary keys, NOT NULL and UNIQUE. The core syntax is standard, but every database has its own types and auto-increment syntax — which is exactly what this generator handles for you.

The same column in five databases

GenericMySQLPostgreSQLSQLiteSQL ServerOracle
Auto-increment idINT AUTO_INCREMENTINTEGER GENERATED BY DEFAULT AS IDENTITYINTEGER PRIMARY KEY AUTOINCREMENTINT IDENTITY(1,1)NUMBER GENERATED BY DEFAULT AS IDENTITY
BOOLEANTINYINT(1)BOOLEANINTEGERBITNUMBER(1)
VARCHAR(255)VARCHAR(255)VARCHAR(255)TEXTNVARCHAR(255)VARCHAR2(255)
TEXTTEXTTEXTTEXTNVARCHAR(MAX)CLOB
DATETIMEDATETIMETIMESTAMPTEXTDATETIME2TIMESTAMP
JSONJSONJSONBTEXTNVARCHAR(MAX)CLOB
UUIDCHAR(36)UUIDTEXTUNIQUEIDENTIFIERVARCHAR2(36)

Constraints explained

  • PRIMARY KEY uniquely identifies each row and implies NOT NULL. Tick PK on several columns for a composite key.
  • NOT NULL rejects missing values. Use it for every column your application always fills.
  • UNIQUE prevents duplicates, such as two accounts with the same email.
  • DEFAULT fills a value when an INSERT leaves the column out. Numbers, TRUE/FALSE, NULL and functions like CURRENT_TIMESTAMP are written as-is; anything else is quoted as text.

Good schema habits

Use snake_case names, store money in DECIMAL (never FLOAT), store timestamps in UTC, and use utf8mb4 in MySQL so emoji and all languages fit. To load data into the new table, generate the inserts with CSV & Excel to SQL, and tidy any query with the SQL Formatter.

Tools that pair well with the CREATE TABLE Generator

  • JSON to SQL — Paste a JSON array and get SQL that creates the table and inserts every object as a row — nested objects become columns or JSON values, and every string is escaped for your dialect.
  • SQL IN Clause Generator — Paste IDs, emails or codes — one per line, comma-separated or straight from an Excel column — and get a ready-made WHERE … IN (…) clause.
  • SQL to JSON, CSV & Excel — Paste a SQL dump or a few INSERT statements and get the rows back as JSON, CSV or an Excel workbook with one sheet per table.
  • Excel to JSON — Open an .xlsx workbook or paste cells straight from Excel or Google Sheets and get clean JSON.

Frequently asked questions

How do I create an auto-increment primary key?
Use an INT or BIGINT column and tick both PK and AI. The generator writes AUTO_INCREMENT for MySQL, IDENTITY for SQL Server and PostgreSQL/Oracle, and INTEGER PRIMARY KEY AUTOINCREMENT for SQLite.
Does SQL Server support CREATE TABLE IF NOT EXISTS?
No. When IF NOT EXISTS is ticked, the generator wraps the statement in IF OBJECT_ID(N'table', N'U') IS NULL instead.
Can I generate the columns from a spreadsheet?
Yes. Open Infer columns, paste a header row and a few data rows (CSV, Excel cells or JSON) and click Infer — names, types, lengths and NOT NULL are filled in for you.
Are my columns saved?
Your column list is stored in this browser's local storage so it is still there when you come back. Nothing is sent to a server.
Should I use VARCHAR or TEXT?
Use VARCHAR(n) for short values with a known maximum (names, emails, codes) and TEXT for long free-form content. In PostgreSQL both perform the same; in MySQL and SQL Server VARCHAR columns can be indexed fully.

Related tools