SQL Table Generator (CREATE TABLE)
Define your columns in the table editor and get a ready-to-run `CREATE TABLE` statement with the right syntax for your chosen database — MySQL, PostgreSQL, SQLite, SQL Server, or standard SQL.
Last updated: May 27, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is SQL Table Generator (CREATE TABLE)?
Every database has slightly different syntax for the parts of `CREATE TABLE` that vary the most: identifier quoting, auto-increment columns, and certain type names. MySQL uses backticks and `AUTO_INCREMENT`; PostgreSQL uses double quotes and `SERIAL`/`BIGSERIAL` (or `GENERATED BY DEFAULT AS IDENTITY`); SQL Server uses brackets and `IDENTITY(1,1)`; SQLite makes `INTEGER PRIMARY KEY` auto-increment.
This tool takes a single column definition and emits the correct syntax for each dialect. Define your columns once in the table, pick a dialect, and you get a clean CREATE TABLE statement ready to paste into your migration or schema file. Switch dialects to compare how the same schema looks in each database.
How to Use SQL Table Generator (CREATE TABLE)
Set the table name and pick a dialect.
Toggle "IF NOT EXISTS" if you want an idempotent statement.
For each column, set the name, type, length (for VARCHAR/DECIMAL), and constraints (NOT NULL, PRIMARY KEY, UNIQUE, AUTO_INCREMENT, DEFAULT).
Add or remove columns as needed.
Copy the generated SQL.
Common Use Cases
- Bootstrapping a new table for an application schema.
- Comparing CREATE TABLE syntax across MySQL, PostgreSQL, SQLite, and SQL Server.
- Producing initial migration files for ORMs like Sequelize, Prisma, or SQLAlchemy.
- Generating teaching examples for a SQL course.
Example Input and Output
A three-column users table with auto-increment ID for MySQL.
Dialect: MySQL · table: users · columns: id (INT, PK, AUTO_INCREMENT), name (VARCHAR(255), NOT NULL), created_at (TIMESTAMP, DEFAULT CURRENT_TIMESTAMP)CREATE TABLE IF NOT EXISTS `users` (
`id` INT AUTO_INCREMENT NOT NULL,
`name` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
);Privacy
All generation happens in your browser. No table definitions are sent to a server.
Migrations
Generated SQL is a starting point — for production migrations, version-control the SQL file and run it through your migration tool (Flyway, Liquibase, Prisma Migrate, Alembic) so it tracks applied state.
Frequently Asked Questions
Why does PostgreSQL output use SERIAL instead of INT AUTO_INCREMENT?
SERIAL is PostgreSQL's canonical auto-increment type — it creates a sequence and assigns it to the column. For Postgres 10+, GENERATED BY DEFAULT AS IDENTITY is preferred, which is what the "Standard SQL" dialect emits.
Does SQLite need AUTO_INCREMENT?
No. An INTEGER PRIMARY KEY column in SQLite auto-increments by default. The tool emits a plain PRIMARY KEY constraint with no extra keywords.
How do multi-column primary keys work?
Mark each column as PK in the editor. The tool emits a single PRIMARY KEY (col1, col2, ...) constraint at the end of the column list.
Does this generate foreign keys or indexes?
Not yet — this tool focuses on CREATE TABLE column definitions. Add FK and INDEX statements manually after generating the table.
Related Tools
SQL Formatter
Format, minify, convert, compare, and analyze SQL queries in a private browser-based SQL formatter with MySQL and PostgreSQL workflow tools.
CSV to SQL Converter
Convert CSV data into SQL INSERT statements for MySQL, PostgreSQL, SQLite, or SQL Server with optional CREATE TABLE output.
SQL to JSON Converter
Parse SQL INSERT statements and output the rows as JSON objects. Handles quoted identifiers, escaped strings, NULL, TRUE/FALSE, and multiple rows per statement.
SQL to CSV Converter
Parse SQL INSERT statements and produce a CSV table. Supports comma, semicolon, pipe, and tab delimiters with proper RFC 4180 quoting.
SQL to HTML Converter
Parse SQL INSERT statements and render them as an HTML table — with the table name as a caption, configurable CSS class, and optional inline styles.
SQL to XML Converter
Parse SQL INSERT statements and serialize them as XML — configurable root and row element names, NULL handled as xsi:nil, indented output, and optional XML declaration.

