SQL CREATE TABLE Generator
Build CREATE TABLE statements visually for MySQL, PostgreSQL, SQLite and SQL Server — types, keys, defaults, auto-increment — or infer columns from CSV.
CREATE TABLE statement
CREATE TABLE `users` ( `id` INT NOT NULL AUTO_INCREMENT, `email` VARCHAR(255) NOT NULL UNIQUE, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
What is the SQL CREATE TABLE Generator?
The ByteTools SQL CREATE TABLE Generator builds correct DDL from a visual column editor. Define each column's name, type, length, nullability, default value, primary key, unique and auto-increment flags, and the statement updates live for your chosen dialect: MySQL, PostgreSQL, SQLite or SQL Server.
- MySQL, PostgreSQL, SQLite and SQL Server dialects
- Correct identifier quoting per dialect
- Auto-increment mapped to AUTO_INCREMENT, SERIAL, IDENTITY or AUTOINCREMENT
- Composite primary keys and unique constraints
- Column inference from a pasted CSV sample
- Live output with copy and .sql download
How to use the SQL CREATE TABLE Generator
- 1
Pick your SQL dialect and enter a table name.
- 2
Add columns and set the type, length, default and flags for each.
- 3
Or click 'Infer columns from CSV' and paste a header plus sample rows.
- 4
Review the live CREATE TABLE statement and any dialect warnings.
- 5
Copy the SQL or download it as a .sql file.
About the SQL CREATE TABLE Generator
The ByteTools SQL CREATE TABLE Generator builds correct DDL from a visual column editor. Define each column's name, type, length, nullability, default value, primary key, unique and auto-increment flags, and the statement updates live for your chosen dialect: MySQL, PostgreSQL, SQLite or SQL Server.
Dialect differences are handled for you — MySQL gets backtick quoting and AUTO_INCREMENT, PostgreSQL gets SERIAL columns and NUMERIC types, SQL Server gets NVARCHAR and IDENTITY(1,1), and SQLite gets its strict INTEGER PRIMARY KEY AUTOINCREMENT form. String defaults are quoted with proper escaping while numbers and CURRENT_TIMESTAMP pass through raw.
Starting from data instead of a schema? Paste a CSV header with a few sample rows and the tool infers column names and sensible types — integers, decimals with precision, dates, booleans and sized VARCHARs. Everything is generated 100% locally in your browser.
Frequently asked questions
How does auto-increment differ between databases?
MySQL appends AUTO_INCREMENT to the column, PostgreSQL uses the SERIAL or BIGSERIAL pseudo-types, SQL Server uses IDENTITY(1,1), and SQLite requires the exact form INTEGER PRIMARY KEY AUTOINCREMENT. The generator writes the right one automatically when you tick Auto-increment.
Can the tool create a composite primary key?
Yes. Tick Primary key on two or more columns and they are emitted as a table-level PRIMARY KEY (col1, col2) constraint, which is the correct syntax in all four dialects.
How are column types translated between dialects?
You pick a generic type and each dialect renders its own equivalent — BOOLEAN becomes TINYINT(1) in MySQL, BIT in SQL Server and INTEGER in SQLite; VARCHAR becomes NVARCHAR in SQL Server; DATETIME becomes TIMESTAMP in PostgreSQL and DATETIME2 in SQL Server.
How accurate is the CSV type inference?
It examines up to 200 sample rows per column: all-integer columns become INT or BIGINT, decimals get a fitted DECIMAL precision, ISO dates map to DATE or DATETIME, true/false to BOOLEAN, and everything else becomes a VARCHAR sized to the longest value. Always review the guesses — samples cannot reveal every future value.
Why does my default value appear in quotes?
String defaults must be single-quoted in SQL, so text is wrapped and internal quotes are doubled ('It''s'). Plain numbers and recognised keywords like CURRENT_TIMESTAMP, NULL, TRUE and FALSE are emitted without quotes because quoting them would change their meaning.
Related tools
SQL Formatter
Format SQL online: uppercase keywords, new lines before SELECT, FROM, WHERE and JOIN, indented AND/OR conditions. One-line minify included. Free and private.
SQL INSERT Parser
Convert SQL INSERT statements to CSV or JSON online. Parse quoted strings, NULLs, numbers and multi-row VALUES lists directly in your browser.
CSV to JSON Converter
Convert CSV to a JSON array of objects online. Header-row detection, comma/semicolon/tab delimiters and pretty-printed output — 100% in your browser.
Mock JSON Data Generator
Generate fake JSON, NDJSON or CSV test data online. Define fields — names, emails, UUIDs, dates, numbers, enums — and create up to 5000 records.
JSON to TypeScript
Generate TypeScript interfaces from a JSON sample online. Infers types recursively, merges array shapes and marks optional keys — 100% in your browser.