将ociuldr.exe复制到H:\oracle\product\10.2.0\db_1\BIN下, 或者path中的某个文件夹中
用法:
C:\Documents and Settings\tgm>ociuldr
Usage: ociuldr user=... query=... field=... record=... file=...
(@) Copyright Lou Fangxin 2004/2005, all rights reserved.
Notes:
-si = enable logon as SYSDBA
user = username/password@tnsname
sql = SQL file name,one sql per file, do not include ";"
query = select statement
field = seperator string between fields
record= seperator string between records
file = output file name(default: uldrdata.txt)
read = set DB_FILE_MULTIBLOCK_READ_COUNT at session level
sort = set SORT_AREA_SIZE & SORT_AREA_RETAINED_SIZE at session level (UNIT:MB)
hash = set HASH_AREA_SIZE at session level (UNIT:MB)
serial= set _serial_direct_read to TRUE at session level
trace = set event 10046 to given level at session level
table = table name in the sqlldr control file
mode = sqlldr option, INSERT or APPEND or REPLACE or TRUNCATE
log = log file name, prefix with + to append mode
long = maximum long field size
array = array fetch size
head = 第一行是否为字段名(head=on), 默认为off
for field and record, you can use '0x' to specify hex character code,\r=0x0d \n=0x0a |=0x7c ,=0x2c \t=0x09
一、导出数据
d:\>ociuldr
user=test/test@acf
query="select * from test" file=test.txt table=test
二、查看导出内容
1,a
2,b
3,c
4,d
5,e
6,f
三、查看自动生成的控制文件
--
-- Generated by OCIULDR
--
OPTIONS(BINDSIZE=8388608,READSIZE=8388608,ERRORS=-1,ROWS=50000)
LOAD DATA
INFILE 'test.txt' "STR X'0a'"
INTO TABLE test
FIELDS TERMINATED BY X'2c' TRAILING NULLCOLS
(
ID CHAR(40),
NAME CHAR(10)
)
四、可以尝试使用这个控制文件将数据加载到数据库中
d:\>sqlldr
test/test@acf
control=test_sqlldr.ctl
这样数据就加载到数据库中。对于大数据库表的导出ociuldr工具还支持按照不同的批量导出数据,这通过一个参数batch来实现,默认一个batch是
50万条记录,如果不指定batch为2就表示100万条记录换一个文件,默认这个选项值是0,就是指不生成多个文件。
在指定batch选项后,需要指定file选项来定义生成的文件名,文件名中间需要包含“%d”字样,在生成文件时,“%d”会打印成序号,请看以下一个测试:
D:\>ociuldr
user=test/test@acf
query="select * from test" batch=1 file=test_%d.txt table=test
测试了一下,用spool按要求导出10万条记录要好几分钟, 用ociuldr导出来用了一秒,或许一秒都不到。
--转自