Convert IBM DB2 to PostgreSQL

A free online converter that translates IBM DB2 queries into PostgreSQL. Paste your SQL, press Translate, and Query Studio rewrites the syntax that differs between the two databases — instantly, with no login and nothing stored.

Open in the editor →All Query Studio tools

IBM DB2PostgreSQL example

Here is a real IBM DB2 query and the PostgreSQL output Query Studio produces:

IBM DB2 input
SELECT u.id, u.name, COUNT(o.id) AS orders
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.created_at > '2024-01-01' AND u.active = 1
GROUP BY u.id, u.name
HAVING COUNT(o.id) > 3
ORDER BY orders DESC
FETCH FIRST 10 ROWS ONLY;
PostgreSQL output
SELECT
  u.id,
  u.name,
  COUNT(o.id) AS orders
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.created_at > '2024-01-01'
  AND u.active = 1
GROUP BY
  u.id,
  u.name
HAVING
  COUNT(o.id) > 3
ORDER BY
  orders DESC
LIMIT
  10

What changes from IBM DB2 to PostgreSQL

  • Row limiting is converted from IBM DB2's FETCH FIRST n ROWS ONLY to PostgreSQL's LIMIT n, including any OFFSET for pagination.
  • The result is re-indented and keyword-cased in PostgreSQL style so it's ready to paste and run.

How to convert IBM DB2 to PostgreSQL

  1. Open the Query Studio editor and choose IBM DB2 as the “From” dialect.
  2. Choose PostgreSQL as the “To” dialect.
  3. Paste your IBM DB2 query and press Translate — copy the PostgreSQL result.

Try it with your own query

The editor is preloaded with IBM DB2PostgreSQL. You can also explain, format, validate and analyze the result.

Convert IBM DB2 to PostgreSQL now →

IBM DB2 to PostgreSQL FAQ

Is this IBM DB2 to PostgreSQL converter free?

Yes — it's completely free with no account, no sign-up and no usage limits. Your query is processed to return the result and never stored.

Is the IBM DB2 to PostgreSQL conversion accurate?

Query Studio rewrites syntax deterministically using real SQL parsers, so it gives the same result every time. It handles the common differences automatically; always review complex, vendor-specific queries before running them in production.

Other conversions

MySQL to PostgreSQLPostgreSQL to MySQLSQL Server to PostgreSQLPostgreSQL to SQL ServerMySQL to SQL ServerSQL Server to MySQL