gb2312转到utf8
spool出来并用iconv转到utf8
#!/bin/bash
for i in `cat table.txt`
do
/opt/oracle10g/u01/bin/sqlplus -s guomei/xyzmn << EOF
set newpage 0
set linesize 10000
set pagesize 0
set und off
set trimspool on
set colsep,
set echo off
set feedback off
spool ${i}.txt;
select ID||'?t?='||username||'?t?='||NICKNAME||'?t?='||PASSWORD||'?t?='||REGTIME||'?t?='||DISABLED||'?t?='||MOBILE||'?t?='||IDCARD||'?t?='||IDCARD_NAME||'?t?='||ISSET||'?t?='||SERVICE_ENABLE||'?t?='||SERVICE_START_TIME||'?t?='||SERVICE_END_TIME||'?t?='||REALNAME||'?t?='||FACE||'?t?='||SEX||'?t?='||BORN||'?t?='||EMAIL||'?t?='||QUESTION||'?t?='||ANSWER||'?t?='||PROVINCE||'?t?='||CITY||'?t?='||'aaaa'||'?t?='||INFO_UPTIME||'?t?='||SAFE_CODE from ${i} order by id;
spool off;
EOF
iconv -c -f GBK -t UTF-8 ${i}.txt > ${i}_utf8.txt
done;
sqlldr进数据库:
#!/bin/bash
for i in `cat table.txt`
do
echo "UNRECOVERABLE
load data
infile '/opt/test/${i}_utf8.txt'
TRUNCATE into table ${i}
fields terminated by '?t?='
TRAILING NULLCOLS
(ID,username,NICKNAME,PASSWORD,REGTIME,DISABLED,MOBILE,IDCARD,IDCARD_NAME,ISSET,SERVICE_ENABLE,SERVICE_START_TIME,SERVICE_END_TIME,REALNAME,FACE,SEX,BORN,EMAIL,QUESTION,ANSWER,PROVINCE,CITY,INFO_CHKCODE,INFO_UPTIME,SAFE_CODE)" > ${i}.ctl
/opt/oracle10g/u01/bin/sqlldr guomei/abc123 control=${i}.ctl direct=ture errors=5000000 multithreading=ture readsize=102400000 streamsize=102400000 columnarrayrows=200000 bad=${i}.bad log=${i}.log;
done
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/230160/viewspace-611508/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/230160/viewspace-611508/