Data replication from MySQL or others to Oracle database?

    refresh_mysql.pl is originally designed to replicate changed data from Oracle to other databases. But now I find that it can be used to copy or replicate data between different databases such as from MySQL to Oracle. We just need to maintain a table with the same structure as the materialized view log table in Oracle, then manually populate the log rows (data copy), or by triggers (data replication) if the source database support it. So powerful it is for this simple Perl script.

    The log table must contains all the primary key columns and two extra columns ("SEQUENCE$$" and "DMLTYPE$$"). I have test it in the MySQL that the dollar character can appear in column name without any problem. The sample create syntax looks as following :

create table temp_table
{
    SEQUENCE$$    INT NOT NULL PRIMARY KEY,
    DMLTYPE$$     VARCHAR(1) DEFAULT 'I',
    pkey_col1     column_type,
    pkey_col...   column_type
);

    Create a configuration file for it, it will work for you. For multiple database support, I have to remove the double quote in the column name, because it will be treated as an constant string in MySQL.

    After some changes of the code, I have copy some data from MySQL to Oracle database. Because I don't know how to create trigger in MySQL, so I did not test data replication to Oracle, but I believe that it will work fine for tables with small data volume.

Post a comment

SCode:
Mail(*, but will not be displayed):
Home: