当前位置: 移动技术网 > IT编程>数据库>Oracle > 深入ORACLE迁移到MYSQL的总结分析

深入ORACLE迁移到MYSQL的总结分析

2017年12月12日  | 移动技术网IT编程  | 我要评论

中国进出口商品交易会展馆,猩球崛起 下载,二炮手迅雷下载

这两个星期里一直都在忙于一件事儿,就是数据库的迁移问题。没有做的时候感觉这是一件十分轻松的事儿,可是等到实实在在去做去实现的时候,自己傻眼了。这种纠结啊,

在这里先说下遇到的问题:
1。数据库的表结构问题:数据类型不同需要解决varchar2------varchar、number-----int、date----datetime,建表的sql语句字段默认值、注释怎么解决。

2. oracle中没有所谓的敏感字段,可是mysql表中的敏感字段有好多。当时出错的时候很奇怪不知道是哪里错了。原来有个describe的字段是mysql的敏感字段。

这里我也是在网上找了一个现成的工具:oracletomysql,它是只能为我们迁移表结构。
具体地址:
3. oracle的备份sql没法正常的mysql中跑,一些to_date()函数,to_char()让人很是痛苦不知道怎么去代替,原因很简单在oracle的备份文件中有一堆的解释文字:

复制代码 代码如下:

prompt pl/sql developer import file
prompt created on 2012-05-30 by chenbh
set feedback off
set define off
prompt disabling triggers for t_b_auditor...
alter table t_b_auditor disable all triggers;
prompt loading t_b_auditor...
insert into t_b_auditor (auditorid, name, orgid, sex, idcardno, title, phone, mobile, describe, auditorright, auditorstatus, recordstatus, field1, field2)

这些东西该怎么除去,大家的想法可能是我直接删除后直接在mysql中跑,可是您想一下如果要是您的备份文件很大很大呢,根本打不开就是。我遇到的sql备份有1g的,电脑不行实在是打不开没有办法只好,从新想其他的办法了。

在这里感谢下:itpub论坛的philip_zhong朋友,这里他给提供了一个程序,来处理大数据量的迁移工作。在这里说下我的使用感言啊,他提供了多种方式,shell脚本、windows下的bat启动、还有源程序。我都试过了,前两者没有调通,只好硬着头皮把他的源程序给跑一下,各种debug修改后终于调通了。很高兴……
这里需要提醒的是:
复制代码 代码如下:

static datasyncdatasourceparameter datasourceparameters;
 static datasyncsessionparameter sessionparameter;
 //static final string configfilename = "config.properties";//这里是源程序中的参数,按照自己的需要进行配置
 static final string configfilename = "config_oracle2mysql.properties";//这里是我的配置文件
 /**
  * @param args
  */
 public static void main(string[] args) {
  // initialize the parameters
  //string progpath = args[0];
  //string progpath = "d://work//myeclipse 8.5//workspaces//datasync";e://workspace//oracletomysql//package
  string progpath = "e://workspace//oracletomysql//package";//这里大家注意下,是你的package的位置所在。
  string conffilepath = progpath + "//conf";
  if (setparameters(conffilepath)) {
   // start to call thread to sync the data
   syncdata();
  }
 }

config_oracle2mysql.properties配置文件:这里需要注意的是:ora_hash是个10g中才有的函数这里我们从新改变下:dbms_utility.get_hash_value这个hash函数是在网上找了好长时间才有人提到的类似与ora_hash的函数。反正这里我的理解就是为了多线程进行大数据量的搬运节约时间,作者才通过hash的方法进行控制。其他注意的地方我已经在程序里写出来一来提醒我注意二来给大家提个醒别犯我的错而浪费大家的时间。
复制代码 代码如下:

#for source database parameters
source.datasource.initialsize=10
source.datasource.maxidle=20
source.datasource.minidle=5
source.datasource.maxactive=100
source.datasource.maxwait=120000
source.jdbc.driverclassname=oracle.jdbc.driver.oracledriver
source.jdbc.url=jdbc:oracle:thin:@10.17.199.8:1521:lab1107
source.jdbc.username=lab1107
source.jdbc.password=lab1107
#target sync data threadnum=source.database.threadnum
source.database.threadnum=10
#这里的auditorid必须是主键,ora_hash是在10g中使用的,我们的9i没办法用啊。
source.database.selectsql=select * from t_b_role where dbms_utility.get_hash_value(roleid,1,#threadnum#)=?
#you can input many commands and split by ";"
source.database.sessioncommand=alter session set db_file_multiblock_read_count=128;
#for target jdbc parameters
target.datasource.initialsize=10
target.datasource.maxidle=20
target.datasource.minidle=5
target.datasource.maxactive=100
target.datasource.maxwait=120000
target.jdbc.driverclassname=com.mysql.jdbc.driver
target.jdbc.url=jdbc:mysql://10.5.110.239:3306/test?autoreconnect=true&characterencoding=utf-8
target.jdbc.username=root
target.jdbc.password=chen
#target.database.insertsql=insert into test2(pathaliasid,path,createtime,lastmodifiedtime,objectprefix,pathmd5id,collideswith) values(?,?,?,?,?,?,?)
target.database.insertsql=insert into t_b_role(roleid,rolename,roledesc,rolestatus,recordstatus,field1,field2,sortnum) values(?,?,?,?,?,?,?,?)这里必须是目标数据库中的现成的一张表。
target.database.commitnum=1000

具体的问题大家要是遇到了,可以一起交流下。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网