Due to some project requirements, it is necessary to import data from Oracle to MySQL regularly, noting that the timeliness of data is not high. Requirements high can use Goldengate
First, you need to export the Vid,userid,goodid,time4 fields from the visit table to
mydb=visit #MySQL数据库名MYUSER =vis_my_user #MySQL用户名MYPASS =is_my_pass # MySQL password ora_name=visit #Oracle实例名ORA_USER =visuser #Oracle用户名ORA_PASS =vispass #Oracle密码 id= ' Mysql -u$myuser -p$mypass $MYDB -N -e "Select max (vid) from visit;" ' #MySQL -n parameter can ignore the first line of output sqlplus -s ${ora_user}/${ora_pass}@${ora_name} << eof set echo off;set feedback off;set newpage none;set verify off; set pagesize 0;set term off;set trims on;set linesize 600;set heading off;set timing off;set numwidth 38; spool /tmp/visit_result.txt; #导出结果位置, the following is a query statement select vid | | ', ' | | userid | | ', ' | | goodsid | | ', ' | | timefrom Visitwhere to_char (Time, ' YYYYMMDD ') >= to_char ( SYSDATE-30, ' YYYYMMDD ') and vid > $idorder by CREATETIME asc; spool off;exiteofmysql -u$myuser -p$mypass $MYDB -e "load data local infile '/tmp/visit_result.txt ' into table visit fields terminated by ', ' (userid,goodsid,time,vid); " #此处为将Oracle数据导入MySQL
This article is from "Maple Night" blog, please be sure to keep this source http://fengwan.blog.51cto.com/508652/1892725
Regularly lead data from Oracle to MySQL