背景:由于即将来临的双十一,业务部门(我司是做京东,天猫的短信服务),短信入库慢,需要DBA把数据库sqlload进数据库。
表结构如下:
MRS VARCHAR2(100),
STATUS VARCHAR2(8),
STATUSTJ VARCHAR2(8),
MMDD VARCHAR2(6),
SN VARCHAR2(20),
ROUTEID NUMBER(4),
RETURNTIME DATE,
RECEIVETIME DATE,
SUBMITTIME DATE,
MTYPE NUMBER(1),
SRSPAN NUMBER,
SPCODE VARCHAR2(21),
BANCHROUTE NUMBER(4),
PROVINCE VARCHAR2(20),
CITY VARCHAR2(20),
USERID NUMBER(10),
SCODE VARCHAR2(25),
UUID VARCHAR2(40)
编写控制文件:
LOAD DATA
INFILE '/u01/app/oracle/utl/daodata/rrpt/rrp_181108.txt'
APPEND
INTO TABLE S_T_RTNRP_STATUS
FIELDS TERMINATED BY ','
(
MRS,
STATUS,
STATUSTJ,
MMDD,
SN,
RETURNTIME date "YYYY-MM-DD hh24:mi:ss",
RECEIVETIME date "YYYY-MM-DD hh24:mi:ss",
ROUTEID,
SUBMITTIME date "YYYY-MM-DD hh24:mi:ss",
MTYPE,
SRSPAN,
SPCODE,
BANCHROUTE,
PROVINCE,
CITY,
USERID,
SCODE,
UUID
)
sqlldr XXX/XXX@db75 control=SqlLdr2.ctl
报错如下:
报错类似如下:
ORA-12899: value too large for column "SMART"."S_T_RTNRP_STATUS"."SCODE" (actual: 32, maximum: 25)
后面修改了表的字段,有原先varchar(20)改成varchar(50)还是报错(由于操作时间,未截图)。
怀疑是字符集的问题,经查实,操作系统的字符集是UTF8,而数据库的字符集是16gbk,导入的PROVINCE, CITY,字段为中文(如下图),后面重新的应用导出数据,不要这两个字段。
SELECT * FROM V$NLS_PARAMETERS WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET')
重新修改控制文件:
LOAD DATA
INFILE '/u01/app/oracle/utl/daodata/rrpt/rrp_181108.txt'
APPEND
INTO TABLE S_T_RTNRP_STATUS
FIELDS TERMINATED BY ','
(
MRS,
STATUS,
STATUSTJ,
MMDD,
SN,
RETURNTIME date "YYYY-MM-DD hh24:mi:ss",
RECEIVETIME date "YYYY-MM-DD hh24:mi:ss",
ROUTEID,
SUBMITTIME date "YYYY-MM-DD hh24:mi:ss",
MTYPE,
SRSPAN,
SPCODE,
BANCHROUTE,
USERID,
SCODE,
UUID
)
export LANG=16GBK
export nls_lang="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
sqlldr xxx/xxx control=SqlLdr2.ctl
后成功导入30多万条记录。