darold / ora2pg

Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects your Oracle database, scan it automatically and extracts its structure or data, it then generates SQL scripts that you can load into PostgreSQL.
http://www.ora2pg.com/
GNU General Public License v3.0
1.02k stars 343 forks source link

Oracle partition tables to migrate to PostgreSQL with same partition names #1584

Closed tayalarun1 closed 1 year ago

tayalarun1 commented 1 year ago

Hello Darold,

I am trying to migrate 2 partition tables from Oracle to PostgreSQL using ora2pg. Here my issue is that both partitioned table have the same name of partitions. For example:

Oracle Code

Create table arun_1 (id number, name varchar2(50), dept number) 
partition by list(dept)
(partition dept_1 values (1),
partition dept_2 values (2),
partition dept_3 values (3));

Create table arun_2 (id number, name varchar2(50), dept number) 
partition by list(dept)
(partition dept_1 values (1),
partition dept_2 values (2),
partition dept_3 values (3));

Now when I generate script via ora2pg v23.2, I get the create table & create partitions(table) as below:

PostgreSQL Code

CREATE TABLE arun_1 (
    id bigint,
    name varchar(50),
    dept bigint
) PARTITION BY LIST (dept) ;

CREATE TABLE dept_1 PARTITION OF arun_1 FOR VALUES IN ('01');
CREATE TABLE dept_2 PARTITION OF arun_1 FOR VALUES IN ('02');
CREATE TABLE dept_3 PARTITION OF arun_1 FOR VALUES IN ('03');

CREATE TABLE arun_2 (
    id bigint,
    name varchar(50),
    dept bigint
) PARTITION BY LIST (dept) ;

CREATE TABLE dept_1 PARTITION OF arun_2 FOR VALUES IN ('01');
CREATE TABLE dept_2 PARTITION OF arun_2 FOR VALUES IN ('02');
CREATE TABLE dept_3 PARTITION OF arun_2 FOR VALUES IN ('03');

So upto create of table arun_2 is good. But as I execute statement:

CREATE TABLE dept_1 PARTITION OF arun_2 FOR VALUES IN ('01');
ERROR:  relation "dept_1" already exists

Please advise.

Thanks Arun

darold commented 1 year ago

Sorry for the response delay, I guess you have found the PREFIX_PARTITION configuration directive. It is now replaced by RENAME_PARTITION to fully rename the partition instead of just prefixing with the table name.