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
978 stars 341 forks source link

Can't extran mysql partition table DDL #1762

Closed codefanhd closed 3 months ago

codefanhd commented 3 months ago

In my MySQL database, a partition table definition like:

note: "/*!50100" isn't normal comment and range_test is a partition definitely

mysql> show create table range_test; +------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | range_test | CREATE TABLE range_test ( a int(11) DEFAULT NULL, b varchar(20) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 */!50100* PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (2500) ENGINE = InnoDB, PARTITION p1 VALUES LESS THAN (5000) ENGINE = InnoDB, PARTITION p2 VALUES LESS THAN (7500) ENGINE = InnoDB, PARTITION p3 VALUES LESS THAN (10000) ENGINE = InnoDB, PARTITION p4 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) / |

use command:

ora2pg -c mysql.dist -a range_test i get a output.sql: -- Generated by Ora2Pg, the Oracle database Schema converter, version 21.1 -- Copyright 2000-2020 Gilles DAROLD. All rights reserved. -- DATASOURCE: dbi:mysql:host=192.168.85.133;database=test;port=3306

SET client_encoding TO 'UTF8';

\set ON_ERROR_STOP ON

CREATE TABLE range_test ( a integer, b varchar(20) ) ; seems like ora2pg can't extract DDL of mysql partition table rightly

please help again!

darold commented 3 months ago

Ok, when I use your DDL I have the following export by type TABLE:

CREATE TABLE range_test (
        a integer,
        b varchar(20)
) PARTITION BY RANGE (a) ;

end for export type PARTITION:

CREATE TABLE range_test_part1 PARTITION OF range_test
FOR VALUES FROM (MINVALUE) TO (2500);
CREATE TABLE range_test_part2 PARTITION OF range_test
FOR VALUES FROM (2500) TO (5000);
CREATE TABLE range_test_part3 PARTITION OF range_test
FOR VALUES FROM (5000) TO (7500);
CREATE TABLE range_test_part4 PARTITION OF range_test
FOR VALUES FROM (7500) TO (10000);
CREATE TABLE range_test_part_default PARTITION OF range_test DEFAULT;

I guess that you have enabled DISABLE_PARTITION in ora2pg.conf.

No problem detected here, closing.