您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

数据批量导入Oracle数据库

2024/11/27 0:31:20发布21次查看
sql*loader是大型数据 仓库选择使用的加载方法,因为它提供了最快速的途径(direct,parallel)。现在,我们抛开其理论不谈,用实例来使 您快速掌握sql*loader的使用方法。 首先,我们认识一下sql*loader。 在nt下,sql*loader的命令为sqlldr,在unix下一般为s
sql*loader是大型数据
仓库选择使用的加载方法,因为它提供了最快速的途径(direct,parallel)。现在,我们抛开其理论不谈,用实例来使
您快速掌握sql*loader的使用方法。
首先,,我们认识一下sql*loader。
在nt下,sql*loader的命令为sqlldr,在unix下一般为sqlldr/sqlload。
如执行:d:oracle>sqlldr
sql*loader: release 8.1.6.0.0 - production on 星期二 1月 8 11:06:42 2002
(c) copyright 1999 oracle corporation. all rights reserved.
用法: sqlload 关键字 = 值 [,keyword=value,...]
有效的关键字:
userid -- oracle username/password
control -- control file name
log -- log file name
bad -- bad file name
data -- data file name
discard -- discard file name
discardmax -- number of discards to allow (全部默认)
skip -- number of logical records to skip (默认0)
load -- number of logical records to load (全部默认)
errors -- number of errors to allow (默认50)
rows -- number of rows in conventional path bind array or between direct p
ath data saves
(默认: 常规路径 64, 所有直接路径)
bindsize -- size of conventional path bind array in bytes(默认65536)
silent -- supdivss messages during run (header,feedback,errors,discards,part
itions)
direct -- use direct path (默认false)
parfile -- parameter file: name of file that contains parameter specification
s
parallel -- do parallel load (默认false)
file -- file to allocate extents from
skip_unusable_indexes -- disallow/allow unusable indexes or index partitions(默认false)
skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable(默认false)
commit_discontinued -- commit loaded rows when load is discontinued(默认false)
readsize -- size of read buffer (默认1048576)
please note: 命令行参数可以由位置或关键字指定。
前者的例子是 'sqlload scott/tiger foo';
后者的例子是 'sqlload control=foo userid=scott/tiger'.
位置指定参数的时间必须早于但不可迟于由关键字指定的参数。例如,
'sqlload scott/tiger control=foo logfile=log',
但'不允许 sqlload scott/tiger control=foo log',
即使允许参数 'log' 的位置正确。
d:oracle>
我们可以从中看到一些基本的帮助信息,这里,我用到的是中文的win2000 adv server。
我们知道,sql*loader只能导入纯文本,所以我们现在开始以实例来讲解其用法。
一、已存在数据源result.csv,欲倒入oracle中fancy用户下。
result.csv内容:
1,默认 web 站点,192.168.2.254:80:,running
2,other,192.168.2.254:80:test.com,stopped
3,third,192.168.2.254:81:thirdabc.com,running
从中,我们看出4列,分别以逗号分隔,为变长字符串。
二、制定控制文件result.ctl
result.ctl内容:
load data
infile 'result.csv'
into table resultxt
(resultid char terminated by ',',
website char terminated by ',',
ipport char terminated by ',',
status char terminated by whitespace)
说明:
infile 指数据源文件 这里我们省略了默认的 discardfile result.dsc badfile result.bad
into table resultxt 默认是insert,也可以into table resultxt append为追加方式,或replace
terminated by ',' 指用逗号分隔
terminated by whitespace 结尾以空白分隔
三、此时我们执行加载:
d:>sqlldr userid=fancy/testpass control=result.ctl log=resulthis.out
sql*loader: release 8.1.6.0.0 - production on 星期二 1月 8 10:25:42 2002
(c) copyright 1999 oracle corporation. all rights reserved.
sql*loader-941: 在描述表resultxt时出现错误
ora-04043: 对象 resultxt 不存在
提示出错,因为数据库没有对应的表。
四、在数据库建立表
create table resultxt
(resultid varchar2(500),
website varchar2(500),
ipport varchar2(500),
status varchar2(500))
/
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product