SQL Loader
程序员文章站
2022-03-10 15:48:52
...
1, Only One Column
Data:
test1.csv at /home/fjccwt/tmp/Data/test1.csv
18305960777
18305960778
18305960779
Control File:
test1.ctl at /home/fjccwt/tmp/test1.ctl
Situation 1 (Only One Input File):
LOAD DATA
INFILE '/home/fjccwt/tmp/Data/test1.csv'
APPEND INTO TABLE TB_ACCURATE_TOPUSH_LIST
FIELDS TERMINATED BY WHITESPACE OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
F_PHONE,
F_IMPORT_TIME SYSDATE,
F_TYPE "50",
F_ISMATCH "0")
Situation 2 (Multiple Input Files):
LOAD DATA
INFILE '/home/fjccwt/tmp/data/test1.csv'
INFILE '/home/fjccwt/tmp/data/test2.csv'
APPEND INTO TABLE TB_ACCURATE_TOPUSH_LIST
FIELDS TERMINATED BY WHITESPACE OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
F_PHONE,
F_IMPORT_TIME SYSDATE,
F_TYPE "49",
F_ISMATCH "0")
2, Multiple Input Fields
Data:
test1.csv at /home/fjccwt/tmp/Data/test1.csv
18305960777,Amy
18305960778,Damon
18305960779,Lucy
Control File:
test1.ctl at /home/fjccwt/tmp/test1.ctl
LOAD DATA
INFILE '/home/fjccwt/tmp/Data/test1.csv' "str x'0D'"
INFILE '/home/fjccwt/tmp/Data/test2.csv' "str x'0D'"
APPEND INTO TABLE TB_ACCURATE_TOPUSH_LIST
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
F_ID "SQ_TB_BIGTURNTABLE_AWARD_LIMIT.nextval",
F_PHONE,
F_NAME,
F_IMPORT_TIME SYSDATE,
F_TYPE "49",
F_ISMATCH "0")
"str x'0D'": If you have multiple fields and have new line characters, you must include this to exclude new line characters from the final database fields (that is, you don't want to include new line characters in the final results);
3, Run The Command
sqlldr fjwechat/fjw2015#@fjwechat_pri control=/home/fjccwt/tmp/test1.ctl log=/home/fjccwt/tmp/test1.log
下一篇: Redis集群