This website use cookies to help you have a superior and more admissible browsing experience on the website.
Loading...
As enterprises modernize their IT infrastructure and pursue cost-effective, scalable database solutions, many have chosen to migrate Oracle database to PostgreSQL. PostgreSQL’s open-source nature, flexibility, and enterprise-grade features make it a powerful alternative to Oracle. However, executing a successful oracle database to PostgreSQL migration requires planning, the right tools, and a deep understanding of both environments.
The motivation to migrate Oracle database to PostgreSQL often stems from a need to reduce licensing costs, eliminate vendor lock-in, and embrace open standards. PostgreSQL offers comparable—or even superior—capabilities in terms of performance, extensibility, and community support.
Unlike Oracle’s commercial model, PostgreSQL is completely open-source and highly customizable. It supports advanced features such as JSONB data types, partitioning, full ACID compliance, and advanced indexing methods. These attributes make PostgreSQL not only a cost-effective choice but also a technically robust one.
While PostgreSQL is a strong alternative, database migration from Oracle to PostgreSQL is not without challenges. The two databases differ in SQL dialects, procedural languages, and internal architectures.:
Next I will show you two ways to manually migrate Oracle to PostgreSQL, including using Foreign Data Wrappers and CSV files.
It’s a common method to migrate Oracle database to PostgreSQL is through Foreign Data Wrappers (FDW). This method allows PostgreSQL to directly access and query Oracle tables as if they were local objects. Instead of transferring all data at once, FDW establishes a live connection between Oracle and PostgreSQL, making it suitable for phased or hybrid migration scenarios.
Step 1: Prepare the Environment
Before starting, make sure the PostgreSQL server can communicate with the Oracle instance. You’ll need to install and configure the Oracle client (for example, Oracle Instant Client) on the PostgreSQL host to enable remote connectivity.
Step 2: Enable the oracle_fdw Extension
In your target PostgreSQL database, run:
CREATE EXTENSION oracle_fdw;
This enables PostgreSQL to interact with Oracle through the FDW interface.
Step 3: Define the Oracle Server Connection
Next, create a foreign server definition in PostgreSQL to specify Oracle connection details:
CREATE SERVER oracle_srv
FOREIGN DATA WRAPPER oracle_fdw
OPTIONS (dbserver ‘//oracle_host:1521/ORCL’);
Here, oracle_srv represents your remote Oracle database connection.
Step 4: Grant Access Permissions
Allow a PostgreSQL user to use the defined foreign server:
GRANT USAGE ON FOREIGN SERVER oracle_srv TO pg_user;
Step 5: Create a User Mapping
Map the PostgreSQL user to Oracle credentials:
CREATE USER MAPPING FOR pg_user
SERVER oracle_srv
OPTIONS (user ‘ora_user’, password ‘ora_pwd’);
Step 6: Create a Foreign Table in PostgreSQL
Now, define a foreign table in PostgreSQL that corresponds to an existing Oracle table:
CREATE FOREIGN TABLE oradata (
id integer OPTIONS (key ‘true’) NOT NULL,
description varchar(100),
amount numeric
)
SERVER oracle_srv
OPTIONS (schema ‘ORA_SCHEMA’, table ‘ORACLE_TABLE’);
After this, you can query oradata as if it were a native PostgreSQL table.
Step 7: Validate the Connection
You can test your setup by executing:
SELECT * FROM oradata WHERE id = 123;
PostgreSQL will fetch the result from the Oracle database behind the scenes.
Step 8: (Optional) Import Data into Local Tables
If your goal is a full migration, you can transfer the Oracle data into PostgreSQL-native tables:
CREATE TABLE local_data AS
SELECT * FROM oradata;
Although FDW is convenient for testing and lightweight integration, it can face performance issues when dealing with complex queries or large datasets, as most operations are executed remotely on the Oracle side. It also lacks real-time synchronization, meaning updates in Oracle are not instantly reflected in PostgreSQL.
Another concern is configuration and maintenance. User mappings and network settings must be handled securely to prevent unauthorized access, while data type conversions and transaction handling can introduce compatibility or consistency challenges during high-concurrency workloads.
If you want to migrate Oracle database to PostgreSQL without requiring real-time synchronization or complex configuration, the CSV method is a simple and universal choice. This approach involves exporting Oracle tables into CSV files and then importing those files into PostgreSQL. Below is a step-by-step explanation along with its advantages and limitations.
Step 1: Export Oracle Data to CSV
Use Oracle tools such as SQL Developer, SQL*Plus, or SQLcl to export your target tables or schema into CSV files. During export, pay attention to encoding (for example, UTF-8), column order, and whether to include headers.
Step 2: Create Corresponding Tables in PostgreSQL
In PostgreSQL, create tables that match the Oracle schema. Map data types appropriately—for example, convert VARCHAR2 to TEXT or VARCHAR, and NUMBER to NUMERIC or BIGINT. Make sure primary keys, constraints, and indexes are properly defined.
Step 3: Transfer CSV Files to the PostgreSQL Host
Copy or upload the exported CSV files to the PostgreSQL server or a directory that PostgreSQL can access.
Step 4: Import Data Using COPY or \copy Command
Run the following command in PostgreSQL to import the CSV file:
COPY target_table (col1, col2, …)
FROM ‘/path/to/file.csv’
WITH (FORMAT csv, HEADER true, ENCODING ‘UTF8’);
Alternatively, you can use the \copy command from the psql client to import files locally.
Step 5: Verify Data Consistency
After importing, verify the results by comparing record counts, checking key uniqueness, computing summary statistics (min/max/avg), or sampling data to confirm that the values match between Oracle and PostgreSQL.
Step 6: (Optional) Handle Incremental Changes
If Oracle data changes after the initial export, you can capture and re-import incremental updates—using timestamp columns or change logs—to keep PostgreSQL synchronized with the latest data.
The main advantage of the CSV method is its simplicity. It is supported by nearly all database systems, requires no additional tools or drivers, and is easy to perform for initial or bulk data migrations. It is also ideal for controlled environments or networks where direct Oracle–PostgreSQL connectivity is restricted.
However, the CSV method comes with clear limitations. It does not support real-time synchronization—once the export is complete, new Oracle updates are not automatically reflected in PostgreSQL. For large datasets, the export and import process can be time-consuming and resource-intensive, sometimes limited by I/O or memory. Handling special fields like dates, null values, or encoding may also introduce conversion errors and require additional cleaning. Finally, when transferring massive CSV files across networks, there is a risk of transmission delays or failures, and this batch-based approach cannot guarantee transaction-level consistency.
Do you feel that both methods are very complex and full of too many uncertainties? Would you prefer a simpler and more efficient method to direct data migration from heterogeneous databases?
If I’m right please make sure you read carefully the method I’m going to talk about next. i2Stream from info2soft provides an intelligent, reliable, and fully automated solution.
Unlike traditional migration utilities or open-source tools, i2Stream is purpose-built for real-time data synchronization and heterogeneous database migration. Key advantages of i2Stream in Oracle to PostgreSQL migration include:
By leveraging i2Stream, organizations can migrate Oracle database to PostgreSQL with confidence—achieving zero data loss, minimal downtime, and maximum efficiency. It transforms migration into a controlled, monitored, and highly automated process suitable for mission-critical workloads.
The decision to migrate Oracle database to PostgreSQL is more than a technical upgrade—it’s a strategic investment in flexibility, cost savings, and modernization. While manual migration can be challenging, using professional tools like i2Stream simplifies the process and ensures reliability at every stage.
As data-driven enterprises continue to evolve, combining PostgreSQL’s scalability with i2Stream’s intelligent synchronization will enable smooth, secure, and high-performance database migration from Oracle to PostgreSQL—without compromising data integrity or business continuity.