SQL Table Generator
Generate CREATE TABLE SQL statements with types, constraints, and keys.
Load Preset Sample:
Columns
Name
Type
Default
Null / PK / AI / UQ
Total Columns3
Primary Key(s)id
DialectMySQL
Output Size177 bytes
Generated SQL
SQL CREATE TABLE Generator
This tool generates syntactically correct CREATE TABLE statements for MySQL, PostgreSQL, SQLite, and SQL Server. Add and configure columns with data types, nullability, default values, primary key, auto-increment, and unique constraints. Each dialect uses its native syntax: MySQL uses AUTO_INCREMENT, PostgreSQL uses SERIAL, SQLite uses INTEGER PRIMARY KEY AUTOINCREMENT, and SQL Server uses IDENTITY(1,1). Boolean columns map to TINYINT(1) in MySQL and BIT in SQL Server for maximum ORM compatibility. Everything runs in your browser with no data sent to any server.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Producing a CREATE TABLE statement from a column list.
- Getting constraint and key syntax right without looking it up.
- Designing a table visually before writing the migration.
- Producing a statement to review before running it.
- Generating a starting schema for a prototype.
Frequently Asked Questions
- How do I choose between VARCHAR and TEXT?
- In PostgreSQL there is no performance difference — `text` and `varchar(n)` are the same underneath and the length is a constraint. In MySQL they differ substantially: `VARCHAR` is stored inline and indexable in full, `TEXT` is stored separately with a prefix index.
- Should the primary key be an integer or a UUID?
- An auto-incrementing integer clusters well and keeps indexes small; a UUID can be generated client-side and does not leak row counts. UUIDv4 fragments an index badly, which is why UUIDv7 exists — it is time-ordered and behaves like a sequential key.
- What does a foreign key actually enforce?
- That the referenced row exists, on insert and update, and what happens on delete — `CASCADE`, `SET NULL` or `RESTRICT`. Choosing `CASCADE` without thinking is how deleting one user removes half the database, so the default of `RESTRICT` is the safer starting point.
- Which columns need an index?
- Those used in `WHERE`, `JOIN` and `ORDER BY` — and not many more. Every index costs write time and storage, and an index on a low-cardinality column such as a boolean is rarely used by the planner at all.
- Should timestamps store a timezone?
- Yes — `timestamptz` in Postgres, which stores UTC and converts on retrieval. A naive timestamp is ambiguous the moment two servers are in different zones or daylight saving shifts, and the resulting bugs surface twice a year and are hard to reproduce.
Common errors and gotchas
- Using a dialect-specific type that the target database does not have.
- Omitting NOT NULL where it belongs, which lets bad rows in from day one.
- Choosing a text type without a length where the database requires one.
- Forgetting indexes, which are cheap to add now and painful on a large table later.
- Generating a statement without a migration, so the schema and the code drift apart.
Related Developer Utilities tools
RegExp Tester
Test regular expressions and inspect matches locally.
Regex Visualizer
Visual regex pattern diagram with live match highlighting and capture group annotations.
Subnet Calculator
Compute CIDR subnets, usable hosts, and network ranges.
Cron Parser
Translate cron syntax into plain English.
URL Parser
Break a URL into protocol, host, path, and query parts.
HTML Previewer
Paste HTML and see it rendered live in a safe, sandboxed preview.
HTTP Status Code Reference
Search and look up every HTTP status code and its meaning.
MIME Type Lookup
Find the MIME type for a file extension, or the extensions for a MIME type.