处理过程:
1、本地建立控制文件
load data
infile ‘d:\TMP_KAITOUSHUJU.csv‘
into table TMP_KAITOUSHUJU
fields terminated by ‘,‘
(TRADE_CO,FULL_NAME,CUSTOMS_CODE,CO_CLASS,VALID_DATE,RG_DATE,ADDR_CO,BUSI_TYPE,CONTAC_CO,TEL_CO,LAW_MAN,LAW_MAN_TEL,CO_TYPE,BREAK_LAW_TIME1,BREAK_LAW_TIME2,INSPECT_TIME,COP_MODIFY_DATE)
2、WINDOWS下运用如下命令执行导入
sqlldr userid=test/test@PORTGB control=d:/TMP_KAITOUSHUJU.ctl log=d:/SQLLOAD.log
3、导入出错,提示部分列为空,查语法后改正控制文件如下
load data
infile ‘d:\TMP_KAITOUSHUJU.csv‘
into table TMP_KAITOUSHUJU
fields terminated by ‘,‘
trailing nullcols --将所有不在纪录中的指定位置的列当作空值
(TRADE_CO,FULL_NAME,CUSTOMS_CODE,CO_CLASS,VALID_DATE,RG_DATE,ADDR_CO,BUSI_TYPE,CONTAC_CO,TEL_CO,LAW_MAN,LAW_MAN_TEL,CO_TYPE,BREAK_LAW_TIME1,BREAK_LAW_TIME2,INSPECT_TIME,COP_MODIFY_DATE)
4、导入成功,但打开一看乱码
通过select * from v$nls_parameters; 查看NLS_CHARACTERSET为AL32UTF8,
而我本机是GBK,于是本机通过DOS窗口进行如下设置:
set NLS_LANG=AMERICAN_AMERICA.AL32UTF8
同时更改控制文件如下:
load data
CHARACTERSET AL32UTF8 (在ctl文件加上字符集,与oracle的字符集相同即可 select * from v$nls_parameters t where t.PARAMETER =‘ NLS_CHARACTERSET‘;)
infile ‘d:\TMP_KAITOUSHUJU.csv‘
into table TMP_KAITOUSHUJU
fields terminated by ‘,‘
trailing nullcols --将所有不在纪录中的指定位置的列当作空值
(TRADE_CO,FULL_NAME,CUSTOMS_CODE,CO_CLASS,VALID_DATE,RG_DATE,ADDR_CO,BUSI_TYPE,CONTAC_CO,TEL_CO,LAW_MAN,LAW_MAN_TEL,CO_TYPE,BREAK_LAW_TIME1,BREAK_LAW_TIME2,INSPECT_TIME,COP_MODIFY_DATE)
SQLLDR导入乱码问题的解决
标签:details rail har 文件 出错 更改 建立 break 乱码问题