Oracle to PostgreSQL: Database conversion process and best techniques to follow
While Oracle is highly significant to companies that maintain huge databases, this object-relational DBMS is high-priced when it comes to acquisition of ownership. Its strict licensing policy is another drawback to be considered. These are the reasons why some companies are shifting their focus onto better DBMS.
PostgreSQL is one of the DBMS that are great replacements for Oracle because of the similarities of both database systems. Oracle database system boasts of features such as multi-level compression, extensive backup, and flexible storage customization. But PostgreSQL is a superior improvement to Oracle beacsye it has both relational database and object-oriented features. Some of the features are sophisticated locking mechanism, nested transactions, multi-level concurrency control, asynchronous replication, and timely recovery. For projects which require high data integrity and dependability, PostgreSQL is a great option.
When migrating from Oracle to PostgreSQL, there are some steps that must be considered. These are:
- In ‘CREATE TABLE’ statements, export Oracle table definitions
- Convert SQL-statements into PostgreSQL format, and load into target server
- Using CSV as an intermediate storage, export Oracle data
- If necessary, convert into target format and import in PostgreSQL database
- In SQL statements and plain text source code, export Oracle triggers, views, and stored procedures.
- According to PostgreSQL syntax, transform statements and code, then load to target server
For table definitions, there are basic steps that must be followed.
First, it is necessary to get list of all tables:
SQL> select table_name from user_tables;
Now let us extract definition of particular Oracle table:
SQL> set long 2000
SQL> set pagesize 0
SQL> select DBMS_METADATA.GET_DDL(‘TABLE’,'<TABLE NAME>'[,’SCHEMA’]) from DUAL
The resulting script must be post-processed before importing into the destination DBMS as follows:
- all Oracle specific statements must be removed at the end of table DDL (starting from “USING INDEX PCTFREE…”)
- According to a certain table that can be found online, equivalents of PostgreSQL must be converted.
The following step is the export of Oracle data in CSV file format according to the following:
SQL> set heading off
SQL> spool filename.csv
SQL> select column1 || ‘,’ || column2 || … from mytable;
SQL> set colsep ‘,’
SQL> select * from my_table;
SQL> spool off;
PostgreSQL allows to import CSV file into a table via the following statement:
COPY <table name> FROM <path to csv file> DELIMITER ‘,’ CSV;
If there is “Permission denied” error after running this statement, try to use “\COPY” command instead.
From ‘mytable’, get the list of indexes.
SQL> select * from all_indexes where table_name = ‘<TABLE NAME>’;
However, all database objects are stored in upper case in Oracle. Lower case is used as specified. To extract definition of particular indexes, this command is followed:
SQL> set long 1000
SQL> set pagesize 0
SQL> select DBMS_METADATA.GET_DDL(‘INDEX’,'<INDEX NAME>’) from DUAL;
Conversion tools involved in migration from Oracle to PostgreSQL
The above-listed processes may seem simple but are somewhat sophisticated and time-consuming. It is more tasking when it involves a manual migration. As usual, manual migration is born of human factor which is not only time-wasting and monotonous, it leads to data loss or corruption. This is why it is important to search for a special tool which makes the conversion process less daunting.
For this reason, Intelligent Converters Company has created a special tool called ‘Oracle to PostgreSQL’ converter which makes the conversion easy in a single click. Also, the tool doesn’t also reduces sophistication, it automates migration of table definitions, views, data, foreign keys, and indexes & constraints. Find more details about the product at https://www.convert-in.com/ora2pgs.htm
- Boat rental
- Hair Care
- Home Improvement
- HVAC Contractor
- Internet Marketing
- Portable Toilet
- Real Estate
- Self Improvement
- Tennis Court
- Truck Repair