CREATE TABLE SQL Statement Builder
Visually design database tables with columns, data types, and constraints — generate SQL for MySQL, PostgreSQL, SQLite, and SQL Server
Columns
Foreign Keys (optional)
Generated SQL
Pick a dialect, name your columns, check the constraint boxes, and get a valid CREATE TABLE statement — no more second-guessing whether PostgreSQL wants SERIAL or AUTO_INCREMENT. Supports MySQL, PostgreSQL, SQLite, and SQL Server with correct quoting and syntax for each. And everything runs in your browser. Nothing gets uploaded.
How It Works
You fill in the table name and add columns with their data types. Check constraint boxes like PK, NOT NULL, UNIQUE, or AUTO_INCREMENT as needed. The builder reads your selections, maps them to the correct syntax for whichever dialect you picked (MySQL, PostgreSQL, SQLite, or SQL Server), and outputs a ready-to-run CREATE TABLE statement. Foreign keys get appended at the bottom if you’ve defined any.
Examples
Simple Users Table (MySQL)
Starting a new app and need a basic users table with auto-incrementing IDs.
Table: users
Dialect: MySQL
Columns:
id - INT, PK, AI
username - VARCHAR(50), NN, UQ
email - VARCHAR(255), NN, UQ
created_at - DATETIME, Default: CURRENT_TIMESTAMP
CREATE TABLE `users` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(50) NOT NULL UNIQUE,
`email` VARCHAR(255) NOT NULL UNIQUE,
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP
);
E-commerce Orders with Foreign Key (PostgreSQL)
An orders table that references a customers table. PostgreSQL swaps AUTO_INCREMENT for SERIAL automatically.
Table: orders
Dialect: PostgreSQL
Columns:
order_id - INT, PK, AI
customer_id - INT, NN
total - DECIMAL(10), NN
status - VARCHAR(20), Default: 'pending'
FK: customer_id → customers(id)
CREATE TABLE "orders" (
"order_id" SERIAL PRIMARY KEY,
"customer_id" INT NOT NULL,
"total" DECIMAL(10) NOT NULL,
"status" VARCHAR(20) DEFAULT 'pending',
FOREIGN KEY ("customer_id") REFERENCES "customers" ("id")
);
Blog Posts Table (SQLite)
Quick local database for a blog prototype. SQLite has its own AUTOINCREMENT quirks.
Table: posts
Dialect: SQLite
Columns:
id - INT, PK, AI
title - VARCHAR(200), NN
body - TEXT
published - BOOLEAN, Default: FALSE
CREATE TABLE "posts" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"title" VARCHAR(200) NOT NULL,
"body" TEXT,
"published" BOOLEAN DEFAULT FALSE
);
Who Uses This
Scaffold new database tables without memorizing dialect-specific syntax for every project.
Learn CREATE TABLE structure visually and compare how the same table looks across MySQL, PostgreSQL, and SQLite.
Build staging tables for imported CSV data without writing raw DDL from scratch.
Prototype database schemas fast when spinning up an MVP over a weekend.
Common Mistakes
VARCHAR without a length defaults differently across databases. MySQL treats it as VARCHAR(1) in some configs, which truncates your data silently. Always specify a length — 255 is a safe default for most text fields.
Auto-increment only works with integer types (INT, BIGINT, SMALLINT). Checking the AI box on a VARCHAR or TEXT column produces invalid SQL. If you need unique string IDs, use a UUID default instead.
The referenced table and column must already exist in your database when you run the generated SQL. Create parent tables first, then child tables with foreign keys. Running them in the wrong order throws a reference error.
Technical Details
- Processing: 100% client-side — nothing leaves your browser
- Browser Support: Chrome, Firefox, Safari, Edge
- Supported Dialects: MySQL, PostgreSQL, SQLite, SQL Server
- Constraints: PRIMARY KEY, NOT NULL, UNIQUE, AUTO_INCREMENT, DEFAULT, FOREIGN KEY
- Export: Copy to clipboard or download as .sql file
Frequently Asked Questions
What’s the difference between SERIAL and AUTO_INCREMENT?
They do the same thing — generate an auto-incrementing integer — but for different databases. MySQL uses AUTO_INCREMENT as a column modifier. PostgreSQL uses SERIAL (or BIGSERIAL) as a data type that creates a hidden sequence behind the scenes. This builder picks the right one based on the dialect you select.
Can I generate ALTER TABLE statements too?
Not with this tool. It’s built specifically for CREATE TABLE. If you need to modify an existing table, you’ll need to write ALTER TABLE statements separately. That said, you can use this builder to redesign your table from scratch and compare the output with your current schema.
Why does my SQLite output say INTEGER instead of INT?
SQLite requires INTEGER (not INT) for AUTOINCREMENT to work on a primary key column. The builder makes this swap automatically when you check both PK and AI with the SQLite dialect. It is one of those quirks that trips people up when switching between databases.
Do I need to add NOT NULL if I already set PRIMARY KEY?
No. PRIMARY KEY implies NOT NULL in every major database. The builder skips the redundant NOT NULL constraint when PK is checked. You’ll notice the generated SQL won’t include both — that’s intentional, not a bug.
Is the generated SQL safe to run in production?
The SQL is syntactically correct for the chosen dialect, but always review it before running on a production database. Check that data types match your actual needs, that column lengths are appropriate for your data, and that foreign key references point to existing tables. Test on a staging environment first if you can.