MySQL to PostgreSQL converter

Paste MySQL queries or CREATE TABLE statements and get PostgreSQL. The converter rewrites types, quoting and functions, and tells you exactly what it changed and what it could not decide for you.

Runs in your browser. Your SQL is never sent anywhere.

Output · PostgreSQL

How to use it

  1. 1Paste MySQL SQL: one query, a CREATE TABLE, or a whole script.
  2. 2Read the PostgreSQL output on the right. Backticks, types, LIMIT and functions are converted.
  3. 3Open "Check these by hand": those are the places where the two databases behave differently.
  4. 4Copy the result and run it against PostgreSQL.

Frequently asked questions

What does it convert?

Backtick names, AUTO_INCREMENT to SERIAL, TINYINT(1) to BOOLEAN, DATETIME to TIMESTAMP, ENUM to a CHECK constraint, UNSIGNED, table options such as ENGINE and CHARSET, LIMIT offset, count, INSERT IGNORE, ON DUPLICATE KEY UPDATE, and functions such as IFNULL, IF, GROUP_CONCAT, DATE_FORMAT, DATE_ADD and DATEDIFF.

Is the result guaranteed to work?

It is a careful first pass, not a guarantee. Some differences cannot be converted automatically, such as ON UPDATE CURRENT_TIMESTAMP, stored procedures and regular expression syntax. The converter lists each one so you can check it.

Why does LIKE become ILIKE?

MySQL compares text without regard to case under its default collation, and PostgreSQL does not. ILIKE keeps the behaviour you had. Change it back to LIKE if you want case-sensitive matching.

Is my SQL sent anywhere?

No. The conversion runs in your browser, so schemas and queries stay on your machine.

How do I move the data, not just the schema?

Export from MySQL to CSV or use a tool such as pgloader, then load into PostgreSQL. Spectre can connect to both databases, so you can compare the two sides while you migrate.

More free SQL tools

Do it on your real database with Spectre

Spectre is the AI database studio for PostgreSQL, MySQL and SQL Server. Ask in plain language, get SQL and answers backed by your data, and keep it all on your machine.