<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=2826169&amp;fmt=gif">
Start trial

    Start trial

      img-badge-diagram-01

      You have a Db2 estate that still runs the business, a mandate to move off it, and no internal precedent for a migration of this kind. How much work will migrating from Db2 to PostgreSQL involve, and can your team estimate it before committing to a date?

      This post explains how to scope your IBM Db2 environment, estimate schema conversion and data migration effort, identify application changes, assess migration tools, and plan cutover.

      Plan a secure, structured migration from IBM Db2 to PostgreSQL while reducing risk, disruption, and operational complexity

      What a Db2 to PostgreSQL migration actually involves

      A Db2 to PostgreSQL migration involves converting database schemas, transferring data, adapting SQL PL routines and stored procedures, and updating applications to work with PostgreSQL. Conversion tools can automate much of the schema conversion and data migration, but application changes, testing, and cutover planning often require more manual effort.

      The harder part is estimating how much code needs rewriting, which applications depend on Db2-specific behavior, and how much testing you'll need before cutover.

      Identify your Db2 environment and migration scope

      img-people-at-office-on-staircase-15-variation-02IBM Db2 has several platforms and deployment options, and each comes with different migration requirements and tooling support. Db2 LUW has broad support from migration tools, while Db2 for z/OS can require a different approach to data extraction and conversion. Db2 for i, Db2 Warehouse, and Amazon RDS for Db2 also have their own compatibility and access considerations.

      In the 2025 State of Enterprise Technology report, 41.4% of surveyed CIOs rated legacy technical debt as a major application modernization challenge. Inventorying embedded SQL, stored procedures, and integrations helps your team identify that work early.

      Inventory your source platform, version, and the following dependencies:

      • Database count, size, and growth
        How much data needs moving, and how long could the transfer take?
      • SQL PL routines
        How many stored procedures, functions, and triggers need converting, and how complex are they?
      • Embedded and application-side SQL
        Where does your application code depend on Db2-specific syntax or behavior?
      • Batch and scheduled jobs
        Which processes access the database, and what needs updating?
      • Integrations and APIs
        Which upstream and downstream systems depend on Db2, and how will the migration affect them?
      Five Db2 migration inventory areas: database size, SQL routines, application SQL, jobs, and APIs

      Schema conversion: What converts easily and what requires more work?

      Stored procedures, functions, and triggers are typically the hardest Db2 objects to convert to PostgreSQL because they often contain platform-specific business logic. Tables and indexes are generally easier to migrate, although complex structures and dependencies can require manual changes.

      Object category Difficulty What drives the effort What to check
      Tables and indexes Low Scales with object count, largely automated Most structures convert automatically, but check identifier case, constraints, and index compatibility.
      Sequences and identity columns Low to medium Scales with object count; defaults need a decision each Check generated values, defaults, and sequence behavior.
      Views Medium Scales with how much platform-specific SQL each view carries Db2-specific SQL syntax and built-in functions may need rewriting.
      Tablespaces Medium Usually a one-off redesign rather than per-object work PostgreSQL handles storage differently, so you may need to redesign the layout.
      Triggers Medium to high Scales with trigger count and logic complexity Trigger logic and execution behavior may need adapting to PostgreSQL.
      Stored procedures and functions in SQL PL High The largest single block of work; scales with routine count and complexity Complex routines often need rewriting in PL/pgSQL and testing to confirm they preserve the original business logic.

      Difficulty and effort in converting IBM Db2 database objects to PostgreSQL

      Watch for these three issues during schema conversion:

      img-train-tracks-against-sun-01-variation-01
      • Identifier case sensitivity
        Db2 folds unquoted identifiers to uppercase, while PostgreSQL folds them to lowercase. Applications using quoted identifiers may fail if you don't account for the difference.
      • Default values
        Some Db2 column defaults and expressions aren't supported directly in PostgreSQL and need modifying.
      • Built-in functions
        Db2-specific functions may have different names, arguments, or behavior in PostgreSQL. You'll need to identify equivalents and test the results.

      Run a trial schema conversion early to see which objects your tooling can handle and which need manual remediation. Use the results to estimate the development and testing effort before scheduling the full database migration.

      Mapping Db2 data types to PostgreSQL

      Most common Db2 data types have direct PostgreSQL equivalents, but some require changes to preserve precision, encoding, or application behavior. Check the PostgreSQL data type documentation and validate the mappings against your source data.

      Db2 type PostgreSQL type Conversion note
      BIGINT, INTEGER, SMALLINT bigint, integer, smallint Direct mapping
      DECIMAL / NUMERIC numeric Preserve the source precision and scale.
      CHAR(n), VARCHAR(n) char(n), varchar(n) Check character encoding and length semantics.
      CHAR / VARCHAR FOR BIT DATA bytea Decision required. Preserve binary values rather than converting them to text.
      BLOB bytea Check large-object sizes and application handling.
      CLOB / DBCLOB text Check character encoding, particularly for DBCLOB.
      DATE / TIMESTAMP date / timestamp Decision required for TIMESTAMP. PostgreSQL supports up to 6 fractional-second digits, compared with up to 12 in Db2.
      JSON json or jsonb Choose based on whether you need to preserve the original JSON representation.

      Common Db2 to PostgreSQL data type mappings, including types that require additional conversion decisions.

      Agree on how to handle timestamp precision and character encoding before transferring data. 

      • For timestamps with more than six fractional-second digits, agree on the precision-reduction rules and validate the converted values.
      • For binary and double-byte character data, test the conversion with representative values to confirm that PostgreSQL stores and retrieves them correctly.

      How to migrate Db2 data and update dependent applications

      img-person-using-computer-and-learning-icons-03-variation-01Data migration and application remediation can run in parallel. Tools can automate much of the transfer, while application changes require development and testing.

      Moving data from Db2 to PostgreSQL

      The data migration process typically involves two steps:

      1. Initial data load
        Use bulk loading tools to transfer existing data from IBM Db2 to PostgreSQL.
      2. Ongoing synchronization
        If you need to minimize downtime, check whether your source platform and migration tool support change data capture (CDC). AWS DMS supports CDC for eligible Db2 LUW sources, but not Db2 for z/OS.

      Rehearse the transfer and validate record counts, data integrity, and application results before switching over.

      Remediating applications that depend on Db2

      This is where many database migration projects become more complex. Your team needs to identify and address four common issues:

      • Embedded SQL
        Find Db2-specific queries in application code, configuration files, and reports. Some may need rewriting to work with PostgreSQL.
      • Assumptions about Db2 behavior
        Check code that depends on Db2's isolation levels, locking behavior, or query results. PostgreSQL may handle these differently.
      • Application-side logic
        Review business logic in SQL PL stored procedures and functions. Decide which routines to convert to PL/pgSQL and which to move into the application.
      • Integration dependencies
        Identify APIs, services, and downstream systems that connect to Db2. Update connections and test how they behave with PostgreSQL.
      Four Db2 migration issues: embedded SQL, Db2 behavior, application-side logic, and integration dependencies

      Estimate remediation effort based on the number and complexity of affected applications, SQL routines, and integrations.

      What migration tooling covers, and where it stops

      Db2 to PostgreSQL migration tools can automate schema conversion, data transfer, and some procedural code conversion. Their capabilities vary by source platform, and complex business logic and application changes still need manual review.

      Tool category Examples What it handles Limitations
      Dedicated conversion toolkits Ispirer Toolkit Schema, data, and procedural code conversion across supported Db2 platforms Complex SQL PL, triggers, and application dependencies may need manual changes
      Cloud migration tools AWS DMS Schema Conversion and AWS DMS Schema conversion and data migration to supported AWS targets Source support and conversion coverage vary; some Db2 z/OS operations require API or CLI access
      Open-source tools and scripts PostgreSQL community-listed tools Data extraction, loading, and basic schema conversion Limited automation for complex routines; more manual development and testing

      Comparison of Db2 to PostgreSQL migration tool categories, capabilities, and limitations

      Use a trial conversion to identify what your chosen tools can migrate and what your team needs to fix manually. Compare their limitations using our enterprise buyer's guide to migration tools.

      How to plan Db2 to PostgreSQL cutover and post-migration operations

      Choose your cutover approach based on acceptable downtime, data validation requirements, and rollback options.

      Choose your cutover approach

      You have two main options:

      • Hard cutover
        Stop writes to Db2, transfer the remaining data, validate the PostgreSQL database, and switch applications over. This approach requires a planned downtime window.
      • Parallel run
        Keep Db2 active while you validate PostgreSQL against production workloads. Where supported, replication or CDC can keep the target current and reduce the final cutover window.

      Whichever approach you choose, plan for migration risks and agree on your rollback criteria before cutover.

      Rehearse the migration and check:

      • Data integrity
        Compare record counts, aggregates, and business-critical calculations.
      • Application behavior
        Test queries, transactions, integrations, and performance against PostgreSQL.
      • Recovery
        Confirm how you'll restore service if cutover fails, including how you'll handle writes made after switching.

      Use data migration best practices to prepare your validation checks. The same principles of planning a database migration for mission-critical systems apply when coordinating application dependencies and downtime.

      Plan the first 90 days after migration

      Your team needs clear processes for managing PostgreSQL after go-live. Redgate's 2026 State of the Database Landscape found that 39% of respondents still use manual methods to test and deploy database changes. Establish repeatable procedures and assign ownership for:

      • High availability and load balancing
        Configure and test PostgreSQL failover and connection routing.
      • Monitoring
        Track query performance, replication lag, vacuum activity, storage growth, and table or index bloat.
      • Backup and recovery
        Schedule backups, test restores, and confirm your recovery time and recovery point objectives.
      • Security
        Recreate and validate access controls, encryption, auditing, and other PostgreSQL security best practices.
      • Operational ownership
        Assign responsibility for incidents, maintenance, upgrades, and ongoing enterprise PostgreSQL support.

      Where Fujitsu Enterprise Postgres fits

      Fujitsu's database modernization services support migrations from IBM Db2 to PostgreSQL and Fujitsu Enterprise Postgres through:

      • Migration Assessment
        Identifies SQL statements requiring modification and helps your team estimate conversion effort.
      • Data Migration services
        Support schema and data migration, with a completion report documenting the source and target database objects.
      • Health Check and Operations Review
        Assesses database health, performance, and operational readiness.
      • PostgreSQL compatibility
        Built on PostgreSQL, with support for PostgreSQL-compatible applications and tools, subject to version and feature requirements.
      • Enterprise security
        Additional capabilities for organizations with strict security and compliance requirements.
      • Long-term support
        24/7 global support and extended version support lifecycles.
      Fujitsu’s Migration Assessment service with environment assessment, detailed reporting, and roadmapping

      Talk to the Fujitsu team about a migration assessment to find out which parts of your Db2 estate convert cleanly and which need rework, before you commit to a cutover date.

      Frequently asked questions about Db2 to PostgreSQL migration

      How long does a Db2 to PostgreSQL migration take?

      A Db2 to PostgreSQL migration can take several months or longer, depending on data volume, SQL PL complexity, application dependencies, and testing requirements. A migration assessment helps establish a realistic timeline.

      Can SQL PL stored procedures be converted automatically?

      SQL PL stored procedures can be partially converted automatically using migration toolkits that translate Db2 code into PostgreSQL's PL/pgSQL language. However, complex procedures, exception handling, and Db2-specific functions may require manual changes. Your team should review and test converted procedures to confirm they produce the expected results.

      What are the hardest parts of a Db2 to PostgreSQL migration?

      The hardest parts of a Db2 to PostgreSQL migration are typically converting stored procedures, finding embedded SQL, and adapting applications that depend on Db2-specific transaction isolation, locking, or database functions.

      Does migrating from Db2 to PostgreSQL require application changes?

      Migrating from Db2 to PostgreSQL usually requires application changes, including driver updates, SQL rewrites, and integration testing. Applications using standard SQL through abstraction layers may need fewer changes.

      Can Db2 applications run unchanged on PostgreSQL?

      Db2 applications rarely run unchanged on PostgreSQL. Even applications using standard SQL may need driver and connection changes. Db2-specific functions, SQL PL, and transaction behavior require additional testing and remediation.

      Can Db2 for z/OS be migrated to PostgreSQL?

      Yes, Db2 for z/OS can be migrated to PostgreSQL, but the process is typically more complex than migrating from Db2 LUW. Differences in platform architecture, data extraction, and tooling support may require additional conversion steps or specialized connectivity. Assess your z/OS environment separately to identify the tools, dependencies, and remediation work involved.

      Topics: PostgreSQL, Fujitsu Enterprise Postgres, Database Migration, Enterprise database, Database modernization, Database Tools

      Receive our blog

      Search by topic

      see all >
      Tim Steward
      Principal Data Enterprise Architect, Fujitsu
      Tim has more than 20 years of experience in the industry with significant expertise in RDBMS, including but not limited to Postgres and Oracle, helping customers understand their architectural landscape and how they can leverage open-source database technology.
      Acknowledged as an experienced Technical Leader, Tim has spoken frequently in conferences and written numerous papers and blogs.
      roundel-owl-and-book-01PostgreSQL Insider 
      has a series of technical articles for PostgreSQL enthusiasts of all stripes, with tips and how-to's.
      Explore PostgreSQL Insider >
      Subscribe to be notified of future blog posts
      If you would like to be notified of my next blog posts and other PostgreSQL-related articles, fill the form here.

      Read our latest blogs

      Read our most recent articles regarding all aspects of PostgreSQL and Fujitsu Enterprise Postgres.

      Receive our blog

      Fill the form to receive notifications of future posts

      Search by topic

      see all >