SQL CREATE TABLE Generator
Design a table once and see how to create it in four databases. The same columns become correct CREATE TABLE statements for MySQL, PostgreSQL, SQLite and SQL Server, each with its own types, auto-increment syntax, default functions, string and boolean handling and a way to keep updated_at current. Compare them side by side or pick the one you need.
- Runs in your browser
- No sign-up
- Free to use
How to use SQL CREATE TABLE Generator
- Enter the table name and add the columns.
- Choose keys, defaults, references and options.
- Show all four databases or select one.
- Copy the statements you need.
SQL CREATE TABLE Generator features
Four dialects
MySQL/MariaDB, PostgreSQL, SQLite and SQL Server.
Correct types
TINYINT(1) vs BOOLEAN vs BIT, JSON vs JSONB vs NVARCHAR(MAX).
Identity syntax
AUTO_INCREMENT, GENERATED AS IDENTITY, INTEGER PRIMARY KEY, IDENTITY(1,1).
Defaults translated
CURRENT_TIMESTAMP, SYSUTCDATETIME(), gen_random_uuid(), NEWID().
updated_at everywhere
ON UPDATE in MySQL, triggers in the others.
Differences explained
Notes on what each database lacks or stores differently.
When to use SQL CREATE TABLE Generator
- Writing migrations for software that supports several databases.
- Comparing how databases implement the same table.
- Teaching SQL portability.
- Creating the same table in development (SQLite) and production (PostgreSQL).
SQL CREATE TABLE Generator FAQ
Why do the types differ?
Each database has its own type system: SQL Server uses BIT for booleans and NVARCHAR for Unicode text, PostgreSQL has BOOLEAN and JSONB, SQLite stores most values as INTEGER, REAL or TEXT, and MySQL uses TINYINT(1) for booleans.
How are enums handled?
MySQL has an ENUM type; the others get a text column with a CHECK constraint listing the allowed values.
Why are there triggers?
Only MySQL can update a timestamp automatically with ON UPDATE CURRENT_TIMESTAMP. The other databases get a small trigger that does the same.
Does SQL Server support IF NOT EXISTS?
Not in CREATE TABLE, so the generator uses IF OBJECT_ID(…) IS NULL instead.
Can I convert an existing table?
Yes, with the Database Column Type Converter, which reads a CREATE TABLE statement from one database and writes it for another.
Is anything uploaded?
No. The SQL is generated in your browser.
One table, four databases
SQL is a standard, but CREATE TABLE is where databases differ most. Auto-incrementing keys, boolean and JSON types, Unicode strings, default functions and automatic timestamps are all spelled differently, so a statement written for one database rarely runs unchanged on another. This generator keeps one neutral description of the table and writes it in each database’s own syntax.
Column types are mapped individually. A boolean is TINYINT(1) in MySQL, BOOLEAN in PostgreSQL, INTEGER with a CHECK in SQLite and BIT in SQL Server. JSON is JSON, JSONB, TEXT and NVARCHAR(MAX) with an ISJSON check. Unicode text uses NVARCHAR in SQL Server, and timestamps with time zone become TIMESTAMPTZ, DATETIMEOFFSET or a UTC DATETIME where no zone-aware type exists.
Keys and defaults are translated too. Auto-increment becomes AUTO_INCREMENT, an identity column, INTEGER PRIMARY KEY or IDENTITY(1,1); the current time becomes CURRENT_TIMESTAMP or SYSUTCDATETIME(); UUID defaults become gen_random_uuid(), (UUID()) or NEWID(), with a note for SQLite, which has no UUID function.
Automatic updated_at columns show the differences clearly: MySQL has ON UPDATE CURRENT_TIMESTAMP, and the other three get a trigger written in their own procedural syntax. Foreign keys, unique constraints and indexes are written in each database’s form, including SQL Server’s NO ACTION in place of RESTRICT.
Notes under the output collect what is lost or changed in each database, such as SQLite storing decimals as floating point or MySQL lacking a time-zone-aware type, so portability problems are visible before they reach production.