How to import data from Oracle into PostgreSQL(转)
In this post, we are going to see how to import Oracle data into PostgreSQL.
If you have been using an Oracle database and now want to move to an open source alternative, then PostgreSQL is the best choice because not only is it free but it’s also a powerful RDBMS (relational database management system) with over 30 years of active development with a great reputation for performance, stability, and a very active open source community.
More information about PostgreSQL can be found here: https://www.postgresql.org/about/.
There are several ways to import Oracle data into PostgreSQL. Here we will discuss a few of the methods that are well proven and most popular.
Method 1: Ora2Pg
As the name suggests, Ora2Pg is used to migrate Oracle objects into PostgreSQL. This tool will connect to an Oracle database and generate SQL scripts that contain table structures and data that can be executed against PostgreSQL.
Some of the features include:
- Exports full database schema (such as tables, views including materialized view, sequences, and indexes).
- Exports specific tables.
- Exports user-defined functions, triggers, procedures, and packages.
- Migrates Oracle user-defined types.
- Supports Oracle BLOB object as BYTEA.
- Supports DBLINK as Oracle FDW.
- Supports SYNONYMS as views.
A sample database migration report can be found here: http://ora2pg.darold.net/report.html.
For more information please visit https://ora2pg.darold.net/start.html.
Method 2: Oracle foreign data wrappers (Oracle_fdw)
PostgreSQL can link to other systems to fetch data via foreign data wrappers (FDWs). When we fire a query (e.g., SELECT) against a foreign table, the FDW will fetch the result from the external data source and print the output via foreign table.
Oracle_fdw is used to perform DML operations (SELECT, INSERT, UPDATE, DELETE) on Oracle servers in PostgreSQL, which is covered under the SQL Management of External Data (SQL/MED) standard.
For more information please visit https://github.com/laurenz/oracle_fdw.
参考:https://www.enterprisedb.com/postgres-tutorials/how-import-data-oracle-postgresql