SQL migration script generator
Paste a CREATE TABLE script written for one engine and get the same schema for SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Types, identifier quoting, defaults, constraints, indexes and auto-increment are translated. When something has no exact equivalent, the tool never guesses silently: it adds a review note that names the column. It all runs in your browser, so your schema is never uploaded.
Review notes
Generate a script and anything the tool could not map with confidence shows up here, by column.
The tool could not map these with confidence. Check each one by hand.
Runs in this tab. The converter is plain JavaScript: nothing you paste is sent anywhere or stored, and the page keeps working offline once it has loaded.
What this migration generator converts
- Column types. Every type goes through the table below:
BITbecomesBOOLEAN,DATETIME2becomesTIMESTAMPorDATETIME(6)with its fractional seconds,NVARCHARbecomesVARCHARon UTF-8 targets,MONEYbecomesNUMERIC(19, 4),UNIQUEIDENTIFIERbecomesUUIDorCHAR(36). OracleNUMBER(p),VARCHAR2andCLOB, PostgreSQLSERIALandJSONBand MySQLTINYINT(1)andUNSIGNEDare read on the way in, and a MySQLENUMbecomes aVARCHARwith aCHECKon its values. Types with no equivalent are flagged, not faked. - Auto-increment.
IDENTITY,AUTO_INCREMENT,SERIALand SQLite'sAUTOINCREMENTeach become the target's native form, with the seed and step:GENERATED ... AS IDENTITY (START WITH s INCREMENT BY i)on PostgreSQL and Oracle,AUTO_INCREMENTplus the table optionAUTO_INCREMENT = son MySQL,INTEGER PRIMARY KEY AUTOINCREMENTon SQLite. - Identifier quoting. SQL Server and MySQL get
[brackets]and`backticks`, SQLite gets"double quotes". On PostgreSQL and Oracle, plain names are left unquoted so they fold to lower or upper case the way those engines expect; reserved words and names quoted in a PostgreSQL or Oracle source keep their quotes. - Defaults and CHECK constraints. Engine functions are translated where an equivalent exists (
GETDATE()toCURRENT_TIMESTAMP,NEWID()togen_random_uuid()or the target's UUID function), boolean defaults follow the column type (1becomesTRUEon PostgreSQL), and MySQL and SQLite get expression defaults in parentheses as they require. - Indexes and constraints. CREATE INDEX statements and ALTER TABLE ADD CONSTRAINT are carried over with the target's syntax, constraint names included. MySQL ignores a foreign key written inline on a column, so those become table-level FOREIGN KEY clauses. SQLite cannot add constraints or defaults after CREATE TABLE, so they are folded into the CREATE TABLE.
- Script structure. Each engine gets its own DROP IF EXISTS form (an anonymous PL/SQL block on Oracle). The drops come before the CREATE statements, in reverse order, so dependent tables go first. Transaction wrapping is optional on the engines with transactional DDL, and schema names can be kept, stripped or replaced.
Type mapping reference
SQL Server source types and what the tool emits for each target. Source types from the other engines (SERIAL, NUMBER, VARCHAR2, CLOB, TINYINT(1)) are read as their nearest row here; Oracle NUMBER(p) with no scale becomes SMALLINT, INT or BIGINT by precision.
| SQL Server | PostgreSQL | MySQL | SQLite | Oracle | Notes |
|---|---|---|---|---|---|
BIT |
BOOLEAN |
TINYINT(1) |
INTEGER |
NUMBER(1) |
SQLite has no boolean type and stores 0/1 in an INTEGER. PostgreSQL defaults of 0/1 become FALSE/TRUE. |
TINYINT |
SMALLINT |
TINYINT UNSIGNED |
INTEGER |
NUMBER(3) |
SQL Server TINYINT holds 0..255; MySQL TINYINT is signed (-128..127) unless UNSIGNED. |
SMALLINT |
SMALLINT |
SMALLINT |
INTEGER |
NUMBER(5) |
|
INT / INTEGER |
INTEGER |
INT |
INTEGER |
NUMBER(10) |
|
BIGINT |
BIGINT |
BIGINT |
INTEGER |
NUMBER(19) |
SQLite INTEGER is 64-bit, so BIGINT fits. |
DECIMAL / NUMERIC (p,s) |
NUMERIC (p,s) |
DECIMAL (p,s) |
NUMERIC |
NUMBER (p,s) |
Precision and scale carry over unchanged. |
MONEY |
NUMERIC (19,4) |
DECIMAL (19,4) |
NUMERIC |
NUMBER (19,4) |
Same range and scale as MONEY, in an exact type. PostgreSQL's own MONEY type is locale-dependent, so it is not used. |
SMALLMONEY |
NUMERIC (10,4) |
DECIMAL (10,4) |
NUMERIC |
NUMBER (10,4) |
|
FLOAT |
DOUBLE PRECISION |
DOUBLE |
REAL |
BINARY_DOUBLE |
SQL Server FLOAT is 8 bytes; SQLite REAL is also 8 bytes. |
REAL |
REAL |
FLOAT |
REAL |
BINARY_FLOAT |
4-byte floating point. |
DATETIME2 |
TIMESTAMP |
DATETIME(6) |
TEXT (ISO 8601) |
TIMESTAMP |
DATETIME2 keeps 7 fractional digits; the targets keep 6. SQLite has no date type; ISO 8601 text sorts and compares correctly. |
DATETIME |
TIMESTAMP(3) |
DATETIME(3) |
TEXT (ISO 8601) |
TIMESTAMP(3) |
DATETIME stores milliseconds rounded to 1/300 s. |
DATETIMEOFFSET |
TIMESTAMPTZ |
DATETIME(6) |
TEXT (ISO 8601) |
TIMESTAMP WITH TIME ZONE |
MySQL cannot store the offset; load the values as UTC. |
DATE |
DATE |
DATE |
TEXT (ISO 8601) |
DATE |
Oracle DATE also holds a time of day; Oracle DATE columns going the other way become TIMESTAMP(0) / DATETIME. |
TIME |
TIME |
TIME |
TEXT (ISO 8601) |
INTERVAL DAY(0) TO SECOND |
Oracle has no time-of-day type; the interval holds the time since midnight. |
CHAR (n) / NCHAR (n) |
CHAR (n) |
CHAR (n) |
TEXT |
CHAR (n) |
|
VARCHAR (n) / NVARCHAR (n) |
VARCHAR (n) |
VARCHAR (n) |
TEXT |
VARCHAR2 (n CHAR) |
PostgreSQL and MySQL 8 default to UTF-8, so the N types are not needed. Oracle gets CHAR length semantics so n counts characters, not bytes. |
VARCHAR (MAX) / NVARCHAR (MAX) |
TEXT |
LONGTEXT |
TEXT |
CLOB |
|
TEXT / NTEXT |
TEXT |
LONGTEXT |
TEXT |
CLOB |
TEXT and NTEXT are deprecated in SQL Server itself. |
UNIQUEIDENTIFIER |
UUID |
CHAR (36) |
TEXT |
RAW (16) |
NEWID() defaults become gen_random_uuid() (PostgreSQL 13+), (UUID()) or SYS_GUID(); SQLite gets 32 random hex digits from randomblob. |
BINARY / VARBINARY (n) |
BYTEA |
BINARY (n) / VARBINARY (n) |
BLOB |
RAW (n) |
|
VARBINARY (MAX) / IMAGE |
BYTEA |
LONGBLOB |
BLOB |
BLOB |
|
IDENTITY (seed, step) |
GENERATED ALWAYS AS IDENTITY |
AUTO_INCREMENT |
INTEGER PRIMARY KEY AUTOINCREMENT |
GENERATED ALWAYS AS IDENTITY |
A seed or step other than 1 is written as (START WITH s INCREMENT BY i); see the auto-increment FAQ. |
ROWVERSION / TIMESTAMP |
no equivalent - review note |
no equivalent - review note |
no equivalent - review note |
no equivalent - review note |
SQL Server TIMESTAMP is the row-version counter, not a date. The tool flags every such column instead of guessing. |
Example: SQL Server to PostgreSQL
This is a cut-down version of the tool's sample, converted with DROP statements on, schema names kept and the transaction wrapper off. Because schema names are kept, PostgreSQL needs a dbo schema to exist. IDENTITY becomes GENERATED ALWAYS AS IDENTITY, NVARCHAR becomes VARCHAR, MONEY becomes NUMERIC(19, 4) and GETDATE() becomes CURRENT_TIMESTAMP. The full sample also has a ROWGUIDCOL column. PostgreSQL has no equivalent for it, so it lands in the review notes.
CREATE TABLE dbo.customers ( id INT IDENTITY(1,1) NOT NULL PRIMARY KEY, name NVARCHAR(200) NOT NULL, balance MONEY NOT NULL DEFAULT (0), created DATETIME2 NOT NULL DEFAULT (GETDATE()) );
-- CASCADE drops objects that depend on the table (foreign keys, views). DROP TABLE IF EXISTS dbo.customers CASCADE; CREATE TABLE dbo.customers ( id INTEGER GENERATED ALWAYS AS IDENTITY NOT NULL PRIMARY KEY, name VARCHAR(200) NOT NULL, balance NUMERIC(19, 4) DEFAULT (0) NOT NULL, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL );
SQL migration generator FAQ
Is this SQL migration generator free?
Yes. There is no sign-up and no usage limit. SQLly, a native SQL workbench for macOS, Windows and Linux, publishes it as a free web tool.
Is my schema sent to a server?
No. The converter is plain JavaScript running inside your browser tab. Your DDL is never uploaded, logged or stored, and once the page has loaded it keeps working offline.
Which engines can it convert between?
SQL Server (T-SQL), PostgreSQL, MySQL and MariaDB, SQLite and Oracle, in any direction. The tool can detect the source engine from the syntax, or you can pick it. It converts CREATE TABLE, CREATE INDEX and ALTER TABLE statements; views, procedures and triggers are copied into the output as comments and listed in the review notes.
How does auto-increment translate between engines?
SQL Server IDENTITY becomes GENERATED ALWAYS AS IDENTITY on PostgreSQL and Oracle, AUTO_INCREMENT on MySQL and INTEGER PRIMARY KEY AUTOINCREMENT on SQLite. A seed and step carry over: IDENTITY(1000, 10) becomes GENERATED ALWAYS AS IDENTITY (START WITH 1000 INCREMENT BY 10). MySQL takes the start value as the table option AUTO_INCREMENT = 1000 but has no per-column step, and SQLite always starts at 1; both cases get a review note. MySQL AUTO_INCREMENT, PostgreSQL SERIAL and SQLite AUTOINCREMENT accept explicit ids, so they become GENERATED BY DEFAULT instead of ALWAYS.
What happens to types with no equivalent?
They are emitted as written and listed in the review notes with the column name. ROWVERSION (and SQL Server TIMESTAMP, which is the same row-version counter, not a date), HIERARCHYID, SQL_VARIANT, GEOGRAPHY and GEOMETRY have no cross-engine replacement, so the script fails on those columns until you replace them by hand instead of running with a type that only looks right.
Why do the Oracle and MySQL scripts skip the transaction wrapper?
Both engines commit implicitly before and after CREATE, ALTER and DROP, so BEGIN and COMMIT around them would not make the script atomic: a failure halfway leaves the earlier tables in place. The tool leaves the wrapper out for those two and says so in a comment. SQL Server, PostgreSQL and SQLite run DDL inside a transaction, so their scripts roll back cleanly.
Does it move my data too?
No. This tool converts the schema: table definitions, types, defaults, constraints and indexes. To move rows, generate INSERT statements from a CSV export with the CSV to SQL tool.
How is this different from the SQL converter tool?
The SQL converter rewrites queries: row limits, date functions, string functions and quoting in SELECT, INSERT and UPDATE statements. This tool works on whole schema scripts and knows more about DDL: it reorders column clauses for engines that care (Oracle wants DEFAULT before NOT NULL), moves MySQL foreign keys to table level because MySQL ignores an inline REFERENCES, and folds ALTER TABLE constraints into CREATE TABLE for SQLite.
Related tools
- SQL converterQuery syntax differences (SELECT, JOIN, functions), statement by statement.
- CSV to SQLTurn data files into INSERT statements for the new table.
- SQL formatterTidy the generated script before you run it.
- All free toolsEvery converter and generator on SQLly.
Related on SQLly
Open the old and new database side by side
SQLly is a native SQL workbench for macOS, Windows and Linux. Connect to both databases at once, compare their schemas, and move what the script can’t carry.