0) 控制文件
install.ctl(含序列,不能设direct=true):
load data
infile '/orahome/wangnc/INSTALLDETAIL.dat'
append
into table sys_login_records_detail_1
fields terminated by ','
(
LOGIN_DATE DATE "yyyy-mm-dd" TERMINATED BY whitespace,
FILLER_1 FILLER,
GAME_ID,
FILLER_2 FILLER,
IP,
MAC,
NETBAR_ID,
PROVINCE,
CITY,
LOGIN_TIMES,
id POSITION(1:1) "sys_login_records_detail_seq_1.nextval"
)
install4.ctl(不含序列,可设direct=true):
Load data
infile '/orahome/wangnc/INSTALLDETAIL.dat'
append
into table sys_login_records_detail_1
fields terminated by ','
(
LOGIN_DATE DATE "yyyy-mm-dd" TERMINATED BY whitespace,
FILLER_1 FILLER,
GAME_ID,
FILLER_2 FILLER,
IP,
MAC,
NETBAR_ID,
PROVINCE,
CITY,
LOGIN_TIMES
)
1) 常规导入
sqlldr userid='emoa_sqlldr/"xxx"@db_esuite' \
control=/orahome/wangnc/install.ctl \
log=/orahome/wangnc/install1.log \
bad=/orahome/wangnc/install1.bad
##Space allocated for bind array: 132352 bytes(64 rows)
##Elapsed time was: 00:01:45.85
2) 1000条提交一次
sqlldr userid='emoa_sqlldr/"xxx"@db_esuite' \
control=/orahome/wangnc/install.ctl \
log=/orahome/wangnc/install2.log \
bad=/orahome/wangnc/install2.bad \
rows=1000 readsize=2068000 bindsize=2068000
##Space allocated for bind array: 2068000 bytes(1000 rows)
##Elapsed time was: 00:00:22.80
3) 10000条提交一次
sqlldr userid='emoa_sqlldr/"xxx"@db_esuite' \
control=/orahome/wangnc/install.ctl \
log=/orahome/wangnc/install3.log \
bad=/orahome/wangnc/install3.bad \
rows=10000 readsize=20680000 bindsize=20680000
##Space allocated for bind array: 20680000 bytes(10000 rows)
##Elapsed time was: 00:00:20.25
4) 设置direct=true, 含序列
sqlldr userid='emoa_sqlldr/"xxx"@db_esuite' \
control=/orahome/wangnc/install.ctl \
log=/orahome/wangnc/install4.log \
bad=/orahome/wangnc/install4.bad \
direct=true
##ORA-01400: cannot insert NULL into ("EMOA"."sys_login_records_detail_1"."ID")
5) 设置direct=true, 去掉序列字段, 最快的方式
#SQL> alter table emoa.sys_login_records_detail_1 drop column id;
sqlldr userid='emoa_sqlldr/"xxx"@db_esuite' \
control=/orahome/wangnc/install4.ctl \
log=/orahome/wangnc/install4.log \
bad=/orahome/wangnc/install4.bad \
direct=true
##Elapsed time was: 00:00:10.98
##但是如果有重复数据, 会把唯一索引置为unusable, 要确保数据源已剔重
6) 设置readsize和bindsize到最大值, 高效又稳妥的方式, 最终采纳方案
sqlldr userid='emoa_sqlldr/"xxx"@db_esuite' \
control=/orahome/wangnc/install4.ctl \
log=/orahome/wangnc/install6.log \
bad=/orahome/wangnc/install6.bad \
rows=100160 readsize=20971520 bindsize=20971520 PARALLEL=TRUE
##Space allocated for bind array: 20970240 bytes(10160 rows)
##Elapsed time was: 00:00:14.36