How to use the CREATE TABLE Generator
- Enter the table name and pick your database dialect.
- Add columns: name, type and length, then tick PK, NN (NOT NULL), UQ (UNIQUE) or AI (auto-increment) and set a default if needed.
- Optionally paste a CSV or JSON sample under Infer columns to create the columns automatically.
- Copy the generated
CREATE TABLEstatement 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
| Generic | MySQL | PostgreSQL | SQLite | SQL Server | Oracle |
|---|---|---|---|---|---|
| Auto-increment id | INT AUTO_INCREMENT | INTEGER GENERATED BY DEFAULT AS IDENTITY | INTEGER PRIMARY KEY AUTOINCREMENT | INT IDENTITY(1,1) | NUMBER GENERATED BY DEFAULT AS IDENTITY |
| BOOLEAN | TINYINT(1) | BOOLEAN | INTEGER | BIT | NUMBER(1) |
| VARCHAR(255) | VARCHAR(255) | VARCHAR(255) | TEXT | NVARCHAR(255) | VARCHAR2(255) |
| TEXT | TEXT | TEXT | TEXT | NVARCHAR(MAX) | CLOB |
| DATETIME | DATETIME | TIMESTAMP | TEXT | DATETIME2 | TIMESTAMP |
| JSON | JSON | JSONB | TEXT | NVARCHAR(MAX) | CLOB |
| UUID | CHAR(36) | UUID | TEXT | UNIQUEIDENTIFIER | VARCHAR2(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,NULLand functions likeCURRENT_TIMESTAMPare 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?
Does SQL Server support CREATE TABLE IF NOT EXISTS?
IF OBJECT_ID(N'table', N'U') IS NULL instead.