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 extract MySQL partition table DDL #1752

Closed codefanhd closed 3 months ago

codefanhd commented 3 months ago

In my MySQL database, a partition table definition like:

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!

darold commented 3 months ago

Are you sure that this table is partitioned? Because I think the partitioning part is commented in your DDL above:

/*  !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)    */ 
codefanhd commented 3 months ago

mysql table is partition table definitely。commented just is output of show create table command