一、下载工具:
打开http://www.anysql.net/在其右边找到sqluldr2,然后点击:
二、下载后解压,有各种对应的版本,我们选择linux64位的:
三、将其放到你要执行的linux目录下,修改 $HOME 目录下.bash_profile 增加如下环境变量:
export LD_LIBRARY_PATH=$ORACLE_HOME/bin:$ORACLE_HOME/lib:/lib:/usr/lib
再用 ./sqluldr2_linux64_10204.bin 加上对应的参数执行就可以了。
先执行./sqluldr2_linux64_10204.bin可以看到其参数说明:
[oracle@localhost ~]$ ./sqluldr2_linux64_10204.bin SQL*UnLoader: Fast Oracle Text Unloader (GZIP, Parallel), Release 4.0.1 (@) Copyright Lou Fangxin (AnySQL.net) 2004 - 2010, all rights reserved. Usage: SQLULDR2 keyword=value [,keyword=value,...] Valid Keywords: user = username/password@tnsname sql = SQL file name query = select statement field = separator string between fields record = separator string between records rows = print progress for every given rows (default, 1000000) file = output file name(default: uldrdata.txt) log = log file name, prefix with + to append mode fast = auto tuning the session level parameters(YES) text = output type (MYSQL, CSV, MYSQLINS, ORACLEINS, FORM, SEARCH). charset = character set name of the target database. ncharset= national character set name of the target database. parfile = read command option from parameter file for field and record, you can use '0x' to specify hex character code, \r=0x0d \n=0x0a |=0x7c ,=0x2c, \t=0x09, :=0x3a, #=0x23, "=0x22 '=0x27
1、
./sqluldr2_linux64_10204.bin user=c##scott/scott@orcl query="select * from emp" file="emp.txt"
2、
./sqluldr2_linux64_10204.bin user=c##scott/scott@orcl alter="DISABLE PARALLEL QUERY;" sql=sql/n3.sql charset=AL32UTF8 record=0x0d0x0a file=emp.csv
3、
./sqluldr2_linux64_10204.bin parfile=parfiles/scott query="select * from emp" file=/home/yaokangjun/emp.txt
其中parfile=parfiles/scott为其当前目录parfiles配置文件scott,如scott为:
user=c##scott/scott@orcl charset=ZHS16GBK field=0X1F record=0x0d0x0a alter=set nls_date_format='yyyymmddhh24miss';