DiagramDB / SQL Dialect Converter

SQL Dialect Converter

Move a query or schema from one database to another. The SQL is rewritten for the target dialect, with a list of every change so you can review it. The quick reference below covers the differences that break most migrations.

Conversion uses an AI model (sent only when you click). Max 8,000 characters. Check the result with the SQL validator.

Syntax differences at a glance

TaskMySQLPostgreSQLSQL ServerSQLiteOracle
Quote an identifier`name`"name"[name]"name""NAME"
First 10 rowsLIMIT 10LIMIT 10TOP (10)LIMIT 10FETCH FIRST 10 ROWS ONLY
Skip 20, take 10LIMIT 20, 10LIMIT 10 OFFSET 20OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLYLIMIT 10 OFFSET 20OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY
Auto-increment keyINT AUTO_INCREMENTINT GENERATED ALWAYS AS IDENTITYINT IDENTITY(1,1)INTEGER PRIMARY KEYNUMBER GENERATED AS IDENTITY
Boolean columnTINYINT(1) / BOOLEANBOOLEANBITINTEGERNUMBER(1) / BOOLEAN (23ai)
ConcatenateCONCAT(a, b)a || ba + b / CONCAT(a, b)a || ba || b
NULL fallbackIFNULL(x, 0)COALESCE(x, 0)ISNULL(x, 0)IFNULL(x, 0)NVL(x, 0)
Current timestampNOW()now()SYSDATETIME()datetime('now')SYSTIMESTAMP
Add 7 daysDATE_ADD(d, INTERVAL 7 DAY)d + INTERVAL '7 days'DATEADD(day, 7, d)date(d, '+7 days')d + 7
UpsertON DUPLICATE KEY UPDATEON CONFLICT (k) DO UPDATEMERGEON CONFLICT (k) DO UPDATEMERGE
Return inserted idLAST_INSERT_ID()RETURNING idOUTPUT inserted.idRETURNING idRETURNING id INTO :v
Case-insensitive matchLIKE (collation-dependent)ILIKELIKE (collation-dependent)LIKE (ASCII only)UPPER(a) LIKE UPPER(b)

A migration checklist

  1. Schema first. Convert types (see SQL data types), identity columns, defaults and constraints. Character sets matter: MySQL utf8 is not full UTF-8, so use utf8mb4.
  2. Then queries. Quoting, paging, upserts and date arithmetic cause most breakage.
  3. Watch semantics, not just syntax. Empty string vs NULL in Oracle, case-sensitivity of comparisons, integer division (5/2 is 2 in PostgreSQL and SQL Server, 2.5 in MySQL).
  4. Validate per dialect with the dialect checkers: PostgreSQL, MySQL, SQL Server, SQLite.

Questions

How do I convert MySQL to PostgreSQL?

Change backticks to double quotes, AUTO_INCREMENT to GENERATED … AS IDENTITY (or SERIAL), TINYINT(1) to BOOLEAN, DATETIME to TIMESTAMP, LIMIT x, y to LIMIT y OFFSET x, IFNULL to COALESCE, and ON DUPLICATE KEY UPDATE to ON CONFLICT … DO UPDATE. Paste your SQL above to have it rewritten with a list of each change; for whole databases use a migration tool such as pgloader.

Can SQL be converted automatically between databases?

Most of it, yes: quoting, types, LIMIT/TOP and common functions map cleanly. Some features have no direct equivalent (MySQL ENUM, SQL Server MERGE options, PostgreSQL arrays), and stored procedures differ completely. That is why every change is listed for you to review.

Is my SQL stored?

No. The SQL is sent once to an AI model through Vercel AI Gateway to produce the conversion and is not stored by DiagramDB. The reference table on this page works without sending anything.

What about converting a schema rather than a query?

For CREATE TABLE statements you can also use the DBML editor: paste SQL into “SQL → DBML”, then convert the DBML to PostgreSQL, MySQL, SQL Server or SQLite. That conversion runs entirely in your browser.

Related tools