Migrating From DB2 To PostgreSQL - What You Should Know - Severalnines
Migrating From DB2 To PostgreSQL - What You Should Know - Severalnines
Migrating From DB2 To PostgreSQL - What You Should Know - Severalnines
Whether migrating a database or an application from DB2 to PostgreSQL with only one
type of database knowledge is not sufficient, there are few things to know about the
differences between the two database systems.
PostgreSQL is world’s most widely used advanced open source database. PostgreSQL
database has rich feature set and PostgreSQL community is very strong and they are
continuously improving the existing features and add new features. As per the db-
engine.com, PostgreSQL is the DBMS of the year 2017 and 2018.
As you know DB2 and PostgreSQL are RDBMS but there are some incompatibilities. In
this blog, we can see some of these incompatibilities.
Flexible open source licencing and easy availability from public cloud providers like
AWS, Google cloud, Microsoft Azure.
Benefit from open source add-ons to improve database performance.
You can see in the below image that PostgreSQL popularity is increasing over time as
compared to DB2.
Migration Assessment
The first step of migration is to analyze the application and database object, find out the
incompatibilities between both the databases and estimate the time and cost required for
migration.
REAL
IBM DB2 Single precision floating point number REAL
PostgreSQL
SMALLINT 16-bit integer SMALLINT
TABLESPACE
TABLESPACE clause defines the name of the tablespace in which the newly created
table resides.
Example:
DB2:
IN
PostgreSQL:
TABLESPACE
Example:
DB2:
ORDER BY EMPID
PostgreSQL:
ORDER BY EMPID
LIMIT 10;
DB2:
CREATE TABLE (
);
PostgreSQL:
CREATE TABLE (
);
CEIL/CEILING
CEIL or CEILING returns the next smallest integer value that is greater than or equal to
the input (e.g. CEIL(122.89) returns 123, also CEIL(122.19) returns 123).
DB2:
PostgreSQL:
SELECT CEIL(123.89) ;
SELECT CEILING(123.89) ;
DATE
It converts the input to date values. You can convert DATE function to TO_DATE function
in PostgreSQL.
DB2:
DAY
It returns the day (day of the month) part of a date or equivalent value. The output format
is integer.
DB2:
PostgreSQL:
MONTH
It returns the month part of the date value. The output format is integer.
DB2:
PostgreSQL:
POSSTR
Returns the position of string. The POSSTR function is replaced by POSITION function in
PostgreSQL.
DB2:
Usage : POSSTR(,)
PostgreSQL:
RAND
It returns a pseudorandom floating-point value in the range of zero to one inclusive. You
can replace RAND function to RANDOM in PostgreSQL.
DB2:
PostgreSQL:
SELECT RANDOM();
Tools
You can use some tools to migrate DB2 database to PostgreSQL. Please test the tool
before use it.
Db2topg
It is an automated tool for DB2 to PostgreSQL migration like ora2pg. The scripts in the
db2pg tool converts as much as possible of a DB2 UDB database. This tool does not
work with DB2 zOS. It is very simple to use, you need a SQL dump of your schema
and then use db2pg script to convert it to a PostgreSQL schema.
Full convert
Enterprise tool quickly copies DB2 database to PostgreSQL. The conversion of DB2 to
PostgreSQL database using Full Convert tool is very simple.
Steps:
Conclusion
As we could see, migrating from DB2 to PostgreSQL is not rocket science, but we need
to keep in mind the thing that we saw earlier to avoid big issues in our system. So, we
only need to be careful in the task and go ahead, you can migrate to the most advanced
open source database and take advantage of its benefits.
Related content
October 8, 2021
Sebastian Insausti
Overview of SQL Server Requirements on Linux and Comparison with Windows SQL Server
August 12, 2021
Ashraf Sharif
Subscribe
Products CC
CC MySQL
CCX MariaDB
PostgreSQL
MySQL NDB
TimescaleDB
MySQL Galera
Solutions Developers
CC Training
CC Certification
Corporate
About us
Contact
Careers
Partners
Email
I'm not a robot
reCAPTCHA
Subscribe Privacy - Terms