1.创建测试表
-- Create table
create table TEST
(
HEAD_ID NUMBER(6) not null,
HEAD VARCHAR2(20) not null,
AREA_CODE VARCHAR2(9) not null,
HEAD_LENGTH NUMBER(2),
COMMENTS VARCHAR2(60)
);
2.创建测试文件,文件名为result.txt,文件内容如下
1,021,021,3,上海
2,025,025,3,南京
3,0410,410,4,铁岭
4,0512,512,4,苏州
5,139159,025,7,南京
6,123456789,025,9,test
3.创建ctl文件,文件名为result.ctl,内容如下:
Load data infile 'result.txt'
Append into table test
(
head_id char(6) terminated by ',',
head char(20) terminated by ',',
area_code char(9) terminated by ',',
head_length char(2) terminated by ',',
comments char(60) terminated by ','
)
4.创建批处理文件,文件名为load_data.bat,内容如下
sqlldr userid=username/userpass@SID control=result.ctl log=result.log
pause
5.把上述文件放到同一个目录里面,执行load_data.bat文件就OK了。