From:       To:      

Home > Documentation > DB2 to PostgreSQL

How to Convert IBM DB2 Database to PostgreSQL

[Validate Migration]  [Types

IBM DB2 is one of the world's oldest relational database management systems. However, its high cost of ownership for large databases and strict licensing policy lead some organization to the idea of migrating from DB2 to another DBMS.

Why PostgreSQL?

When planning a database migration, it is logical to review open-source systems in order to reduce total cost of ownership. PostgreSQL offers valuable benefits such as:

DB2 to PostgreSQL Migration Steps

Here are the steps to migrate IBM DB2 database to PostgreSQL:

This is how to make DB2 scripts compatible with PostgreSQL format:

DB2 to PostgreSQL Conversion Tools

As you may see, database migration from IBM DB2 to PostgreSQL is a tedious procedure that requires a lot of efforts. Manual conversion may cause data loss or corruption due to human errors. Fortunately, there are some tools to automate migration from DB2 to PostgreSQL.

db2topg is a set of easy to use Perl scripts to convert DB2 schemas and data into PostgreSQL format. The result is number of SQL scripts that must be run in particular order:

  1. creation of statements of tables, sequences, tablespaces
  2. export.db2 script produces a bunch of del/lob files, containing all tables content
  3. creation of indexes and foreign keys
  4. creation of views, triggers and check constraints

As you may see, this approach requires a lot of intermediate steps that must be handled manually.

In order to get fully automated migration, take a tool at DB2 to PostgreSQL conversion tool.