Oracle 入門和sqluldr2 資料快速匯出工具的使用
Oracle的安裝
oracle的下載,安裝
請參考:
https://www.cnblogs.com/hoobey/p/6010804.html
值得一提的是:
安裝完成,首次啟動Developer的時候,需要制定java.exe的路徑。這個路徑需要選擇oracle安裝目錄下的路徑。
我的機器上,該路徑為:F:\App\Administrator\product\11.2.0\dbhome_1\jdk\bin
另外,若按照如上步驟安裝連續報錯:unable to find a JVM
則是因為安裝的Oracle 11g R2自帶的SQL Develper是32bit的,但給它的JDK環境是64bit的,所以報錯。
只需要從Oracle官網下載F:\App\Administrator\product\11.2.0\dbhome_1
)下的sqldeveloper資料夾,然後重新啟動SQL Developer即可。
sqluldr2
Sqluldr2是一款可以快速匯出oracle資料庫中的資料的小工具。
Oracle在PL/SQL Developer下,匯出檔案較慢,尤其在面對海量資料下載時,一款能夠提速50%-75%資料下載速度的工具顯得尤為重要。Sqluldr2是不錯的選擇。
下載連結:Sqluldr2。
解壓資源
在windows下,只需要在該地址下開啟命令列視窗,直接執行對應的檔案即可。
具體的資料格式和命令:
Usage: SQLULDR2 keyword=value [,keyword=value,...]
Valid Keywords:
user = username/[email protected]
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
read = set DB_FILE_MULTIBLOCK_READ_COUNT at session level
sort = set SORT_AREA_SIZE at session level (UNIT:MB)
hash = set HASH_AREA_SIZE at session level (UNIT:MB)
array = array fetch size
head = print row header(Yes|No)
batch = save to new file for every rows batch (Yes/No)
size = maximum output file piece size (UNIB: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
control = sqlldr control file and path.
mode = sqlldr option, INSERT or APPEND or REPLACE or TRUNCATE
buffer = sqlldr READSIZE and BINDSIZE, default 16 (MB)
long = maximum long field size
width = customized max column width (w1:w2:...)
quote = optional quote string
data = disable real data unload (NO, OFF)
alter = alter session SQLs to be execute before unload
safe = use large buffer to avoid ORA-24345 error (Yes|No)
crypt = encrypted user information only (Yes|No)
sedf/t = enable character translation function
null = replace null with given value
escape = escape character for special characters
escf/t = escape from/to characters list
format = MYSQL: MySQL Insert SQLs, SQL: Insert SQLs.
exec = the command to execute the SQLs.
prehead = column name prefix for head line.
rowpre = row prefix string for each line.
rowsuf = row sufix string for each line.
colsep = separator string between column name and value.
presql = SQL or scripts to be executed before data unload.
postsql = SQL or scripts to be executed after data unload.
lob = extract lob values to single file (FILE).
lobdir = subdirectory count to store lob files .
split = table name for automatically parallelization.
degree = parallelize data copy degree (2-128).
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
oracle資料匯出工具sqluldr2
基本簡介
下載完sqluldr解壓後,資料夾內容如下:
sqluldr2.exe 用於32位windows平臺;
sqluldr2_linux32_10204.bin 適用於linux32位作業系統;
sqluldr2_linux64_10204.bin 適用於linux64位作業系統;
sqluldr264.exe 用於64位windows平臺。
使用方法
1、首先將sqluldr2.exe複製到執行目錄下,即可開始使用
2、檢視help 幫助
sqluldr2 官方下載
3、執行資料匯出命令
3.1、常規匯出
sqluldr2 test/[email protected]/orcl query=”select * from temp_001” head=yes file=d:\tmp001.csv
說明:head=yes 表示輸出表頭
3.2、使用sql引數
sqluldr2 test/[email protected]/orcl sql=test_sql.sql head=yes file=d:\tmp001.csv
test_sql的內容為:
select * from temp_001
3.3、使用log引數
當整合sqluldr2在指令碼中時,就希望遮蔽上不輸出這些資訊,但又希望這些資訊能保留,這時可以用“LOG”選項來指定日誌檔名。
sqluldr2 test/[email protected]/orcl sql=test_sql.sql head=yes file=d:\tmp001.csv log=+d:\tmp001.log
3.4、使用 table 引數
當使用 table 引數時,在目錄下會生成對應的ctl控制檔案,如下語句會生成temp_001_sqlldr.ctl檔案。
sqluldr2 test/[email protected]/orcl query=”select * from temp_001” table=temp_001 head=yes file=d:\tmp001.csv