1.录入excel测试表格,test.xls。
2.另存为.csv格式
3.创建sql*loader控制文件test.ctl,内容如下:
load data
infile 'd:\sqldr\test.csv'
badfile 'd:\sqldr\test.bad'
discardfile 'd:\sqldr\test.dis'
append into table test
fields terminated by ',' optionally enclosed by '"' /*如果是制表符分割,则用fields terminated by X'09'*/
trailing nullcols /*表示如果没有对应的列,则为null*/
(
id,
name
)
需要将数据文件拷贝到对应位置
4.到数据库中建立对应的测试表test
create table test (
id int,
name Varchar2(10)
)
5.执行导入命令
Sqlldr userid = test/test@acf control='d:\sqldr\test.ctl'
导入成功!
附:
Sqlldr的函数关键字说明:
Userid --oracle用户名 userid = username/password
Control --控制文件名称 control = ‘e:\insert.ctl’
Log –-日志文件名称 log = ‘e:\insert.log’
Bad --损坏文件名称
Data --data file name
Discard --discard file name
Discardmax --number of discards to allow(默认全部)
Skip --导入时跳过的记录行数(默认0)
Load --导入时导入的记录行数(默认全部)
Errors --允许错误的记录行数(默认50)
ctl文件内容说明:
Load data
Infile ‘e:\test.csv’ --数据源文件名称
Append|insert|replace --append在表后追加,insert插入空表,replace替代原有内容
Into table test --要导入的数据库表名称
[when id = id_memo] --过滤条件
Fields terminated by X’09’ --字段分隔符
(id,name,telphone) --字段名称列表
2.另存为.csv格式
3.创建sql*loader控制文件test.ctl,内容如下:
load data
infile 'd:\sqldr\test.csv'
badfile 'd:\sqldr\test.bad'
discardfile 'd:\sqldr\test.dis'
append into table test
fields terminated by ',' optionally enclosed by '"' /*如果是制表符分割,则用fields terminated by X'09'*/
trailing nullcols /*表示如果没有对应的列,则为null*/
(
id,
name
)
需要将数据文件拷贝到对应位置
4.到数据库中建立对应的测试表test
create table test (
id int,
name Varchar2(10)
)
5.执行导入命令
Sqlldr userid = test/test@acf control='d:\sqldr\test.ctl'
导入成功!
附:
Sqlldr的函数关键字说明:
Userid --oracle用户名 userid = username/password
Control --控制文件名称 control = ‘e:\insert.ctl’
Log –-日志文件名称 log = ‘e:\insert.log’
Bad --损坏文件名称
Data --data file name
Discard --discard file name
Discardmax --number of discards to allow(默认全部)
Skip --导入时跳过的记录行数(默认0)
Load --导入时导入的记录行数(默认全部)
Errors --允许错误的记录行数(默认50)
ctl文件内容说明:
Load data
Infile ‘e:\test.csv’ --数据源文件名称
Append|insert|replace --append在表后追加,insert插入空表,replace替代原有内容
Into table test --要导入的数据库表名称
[when id = id_memo] --过滤条件
Fields terminated by X’09’ --字段分隔符
(id,name,telphone) --字段名称列表