MySQL数据迁移到Oracle记录
MySQL: utf-8字符集Oracle: Al32UTF8步骤:1. 从mysql导出csv格式数据,导出时设置default_character_set=gbk,否则会乱码2.上传
MySQL: utf-8字符集
Oracle: Al32UTF8
步骤:
1. 从mysql导出csv格式数据,,导出时设置default_character_set=gbk,否则会乱码
2.上传至linux服务器(oracle服务器),用以下命令将windows的\r\n换成\r:
sed -i "s/\r//g" file
3.将gbk编码转为utf8编码:
iconv -f gb18030 -t utf-8 file1.txt > file2.txt
4.编写sql loader控件文件(file.ctl):
options (skip=1)
load data
CHARACTERSET AL32UTF8
infile 'terminal.txt'
badfile 'terminal.err'
discardfile 'terminal.dis'
replace into table terminal
fields terminated by ',' TRAILING NULLCOLS
(
id,
mobile,
imsi,
imei,
evoketime date "yyyy-mm-dd hh24:mi:ss",
province,
city,
evokenum,
createtime date "yyyy-mm-dd hh24:mi:ss",
project_id,
carrier,
ip,
sc,
new_imsi,
new_imei
)
5. 运行sqlldr导入到oracle数据库:
sqlldr user/pass@db -control=file.ctl