Create the demo table and materialized view log in Oracle:
CREATE TABLE T_OBJECTS AS SELECT * FROM DBA_OBJECTS WHERE ROWNUM < 1;
ALTER TABLE T_OBJECTS MODIFY OBJECT_ID NOT NULL;
ALTER TABLE T_OBJECTS ADD PRIMARY KEY (OBJECT_ID);
CREATE MATERIALIZED VIEW LOG ON T_OBJECTS WITH PRIMARY KEY, SEQUENCE;
Create the relative demo table in MySQL:
CREATE TABLE t_objects (
OBJECT_ID decimal(10,0) NOT NULL, OWNER varchar(30) ,
OBJECT_NAME varchar(128) , SUBOBJECT_NAME varchar(30) ,
DATA_OBJECT_ID decimal(10,0) , OBJECT_TYPE varchar(18) ,
CREATED datetime , LAST_DDL_TIME datetime ,
TIMESTAMP varchar(19) , STATUS varchar(7) ,
TEMPORARY varchar(1) , GENERATED varchar(1) ,
SECONDARY varchar(1) , PRIMARY KEY (OBJECT_ID)
);
Create a configuration file (demo.conf):
# SOURCE # PKEY # MVIEW Log # TARGET
T_OBJECTS # OBJECT_ID # MLOG$_T_OBJECTS # T_OBJECGS
Run refresh_mysql.pl to start replication (I run it on windows with ActivePerl):
perl refresh_mysql.pl -s username#password#Oracle:tnsname -t username#password#MySQL:database:hostip -c demo.conf
Now you can run some DML statement on t_objects from Oracle database, and then check whether the changes are applied to MySQL by this script.
Comments (4)
Hello. I am interested in using your script to test in converting some table from Oracle to MySQL, but these are regular Oracle tables. I am not good at Perl, so, do you have another version of this script where it simply connects to the Oracle db, reads the data and then directly inserts it to the empty table in MySQL? Both my Oracle database and MySQL database resides in the same server. Thank you so much in advance for your response.
Posted by Theresa Royales | June 2, 2007 4:09 PM
Are the tables in Oracle and MySQL have the same structure (column name, column count etc). The column order does not matter.
If somebody need this, I could write one.
Posted by anysql | June 2, 2007 4:55 PM
Your migration job from Oracle to MySQL is just a one time job, right?
Posted by anysql | June 2, 2007 4:57 PM
Hello Anysql. (Really sorry for a delayed response, got tiedup to a lot of crazy stuff. Bummer me :( Apologize for that) Anyway, it was a onetime migration from oracle to mysql, and we ended up using shell scripts and used 'load data infile' of mysql. Good thing db was still small at that time. We are now a full-blown mysql shop! Hey, really appreciate the kindness and more power to you.
Posted by tsr | February 28, 2008 2:10 AM