欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Oracle sqlldr 在DOS窗口导入多列数据到数据库表

程序员文章站 2022-08-05 22:07:25
sqlldr 用法详见:https://www.cnblogs.com/rootq/archive/2009/03/01/1401061.html 测试内容: 1、创建数据库表: create table test_sqlldr (test_id number,test_phone number,t ......

sqlldr 用法详见:https://www.cnblogs.com/rootq/archive/2009/03/01/1401061.html

测试内容:

1、创建数据库表:

create table test_sqlldr
(
test_id number,
test_phone number,
test_content varchar2(20)
)

2、写sqlldr脚本:

测试内容包含有:控制文件(sqlldr.ctl)、数据文件(test_sqlldr.txt'  )、坏文件(bad_sqlldr.txt)、日志文件(sqlldr1.txt  )等文件。

 2.1、控制文件:

 load data
infile 'c:\users\air\desktop\test_sqlldr.txt'   --待导入文件位置
badfile 'c:\users\air\desktop\bad_sqlldr.txt'   --坏文件存放地址,导入时因异常原因没能进库的数据会保存到该文件
append
into table test_sqlldr   --待导入的数据库表
fields terminated by "," optionally enclosed by '"'
trailing nullcols  --表的字段没有对应值的时候允许为空
(
test_id,test_phone,test_content
)

2.2、测试数据内容:

Oracle sqlldr 在DOS窗口导入多列数据到数据库表

2.3、在dos窗口执行以下脚本,结果如下图所示:

sqlldr scott/tiger@192.168.0.13:1521/orcl control=c:\users\air\desktop\sqlldr.ctl log=c:\users\air\desktop\sqlldr1.txt   rows=5000

Oracle sqlldr 在DOS窗口导入多列数据到数据库表

2.4、在数据库表中查询数据是否进表(因为像某些数据文件 字段因为数值过大,dos窗口执行脚本也不会报错,数据便不会入表),测试结果详见下图:

Oracle sqlldr 在DOS窗口导入多列数据到数据库表