測試TOM=SQLLDR函式使用1
一個列可以是對一個或者多個其它列引用函式的結果,類似拼接字串那種意思,只不過這裡是列孫是字元
測試
會話1:建立新的控制檔案
[oracle@oraclelinux ~]$ vi dept_load11.ctl
load data
infile *
into table dept_load
replace
fields terminated by ','
(deptno,
dname "upper(:dname)",
loc "upper(:loc)",
last_updated date 'dd/mm/yyyy',
entire_line ":deptno||:dname||:loc||:last_updated"
)
begindata
10,sales,virginia,1/5/2000
20,accounting,virginia,21/6/1999
30,consulting,virginia,5/1/2000
40,finance,virginia,15/3/2001
會話1:載入資料
[oracle@oraclelinux ~]$ sqlldr userid=scott/scott control=dept_load11.ctl
SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 14 13:37:30 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
會話1:檢視錯誤日誌:
[oracle@oraclelinux ~]$ cat dept_load11.log
SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 14 13:37:30 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: dept_load11.ctl
Data File: dept_load11.ctl
Bad File: dept_load11.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table DEPT_LOAD, loaded from every logical record.
Insert option in effect for this table: REPLACE
Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
DEPTNO FIRST * , CHARACTER
DNAME NEXT * , CHARACTER
SQL string for column : "upper(:dname)"
LOC NEXT * , CHARACTER
SQL string for column : "upper(:loc)"
LAST_UPDATED NEXT * , DATE dd/mm/yyyy
ENTIRE_LINE NEXT * , CHARACTER
SQL string for column : ":deptno||:dname||:loc||:last_updated"
Record 1: Rejected - Error on table DEPT_LOAD, column DEPTNO.
Column not found before end of logical record (use TRAILING NULLCOLS)==沒等處理完所有列,記錄中就沒有資料了
Record 2: Rejected - Error on table DEPT_LOAD, column ENTIRE_LINE.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 3: Rejected - Error on table DEPT_LOAD, column ENTIRE_LINE.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 4: Rejected - Error on table DEPT_LOAD, column ENTIRE_LINE.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 5: Rejected - Error on table DEPT_LOAD, column ENTIRE_LINE.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 6: Rejected - Error on table DEPT_LOAD, column DEPTNO.
Column not found before end of logical record (use TRAILING NULLCOLS)
Table DEPT_LOAD:
0 Rows successfully loaded.
6 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 82560 bytes(64 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 6
Total logical records rejected: 6
Total logical records discarded: 0
Run began on Mon May 14 13:37:30 2012
Run ended on Mon May 14 13:37:30 2012
Elapsed time was: 00:00:00.28
CPU time was: 00:00:00.08
[oracle@oraclelinux ~]$
會話1:修改控制檔案
因為資料沒處理完,就沒記錄,所以入果輸入記錄中,不存在某一列的資料,SQLLDR就給該列一個空值,通過TRALING NULLCOLS 會導致繫結變數:ENTIRE_LINE會成為NULL.
[oracle@oraclelinux ~]$ cat dept_load12.ctl
LOAD DATA
INFILE *
INTO TABLE DEPT_LOAD
REPLACE
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(DEPTNO,
DNAME "upper(:dname)",
LOC "upper(:loc)",
LAST_UPDATED date 'dd/mm/yyyy',
ENTIRE_LINE ":deptno||:dname||:loc||:last_updated"
)
BEGINDATA
10,Sales,Virginia,1/5/2000
20,Accounting,Virginia,21/6/1999
30,Consulting,Virginia,5/1/2000
40,finance,virginia,15/3/2001
[oracle@oraclelinux ~]$
會話1:載入資料
[oracle@oraclelinux ~]$ sqlldr userid=scott/scott control=dept_load12.ctl
SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 14 13:48:44 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Commit point reached - logical record count 4
[oracle@oraclelinux ~]$ exit
exit
SQL> select * from dept_load;
DEPTNO DNAME LOC ENTIRE_LINE LAST_UPDA
---------- -------------- ------------- ----------------------------- ---------
10 SALES VIRGINIA 10SalesVirginia1/5/2000 01-MAY-00
20 ACCOUNTING VIRGINIA 20AccountingVirginia21/6/1999 21-JUN-99
30 CONSULTING VIRGINIA 30ConsultingVirginia5/1/2000 05-JAN-00
40 FINANCE VIRGINIA 40financevirginia15/3/2001 15-MAR-01
SQL>
為什麼會是這個效果?SQLLDR在檢視控制檔案中的列,並根據這些列建立繫結變數。
以沒有任何函式的情況為例子,SQLLDR構建INSERT過程如下
INSERT INTO DEPT ( DEPTNO, DNAME, LOC, LAST_UPDATED, ENTIRE_LINE )
VALUES ( :DEPTNO, :DNAME, :LOC, :LAST_UPDATED, :ENTIRE_LINE );
|| ||
|| ||
****** 解析輸入量 *********
||
** *****將值給繫結變數,執行語句****
有函式的情況
INSERT INTO T (DEPTNO, DNAME, LOC, LAST_UPDATED, ENTIRE_LINE)
VALUES ( :DEPTNO, upper(:dname), upper(:loc), :last_updated,
:deptno||:dname||:loc||:last_updated );=====》解析=====》輸入繫結到語句,並執行
上面的測試情況屬於第2種有函式的情況
注:SQL能做的事,SQLLDR都可以結合做。
測試結束
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15720542/viewspace-723504/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 測試TOM=SQLLDR使用函式載入資料SQL函式
- 測試TOM=SQLLDR使用CASE語句SQL
- 測試TOM=SQLLDR生成外部表SQL
- 測試TOM=SQLLDR載入日期資料SQL
- 測試TOM==SQLLDR載入固定格式資料SQL
- 測試oracle sqlldrOracleSQL
- 測試TOM=SQLLDR載入內嵌換行符資料SQL
- sqlldr匯入日期函式SQL函式
- 測試TOM=SQLLOADER1SQL
- Oracle sqlldr工具功能測試OracleSQL
- sqlldr效能調優測試SQL
- 對Largest函式的測試函式
- 測試 JavaScript 函式的效能JavaScript函式
- oracle函式測試小記Oracle函式
- 走進 phantomjs 嵌入式測試JS
- [轉載]使用uiautomator做UI測試UI
- sqlldr批量匯入匯出資料測試SQL
- sqlldr批次匯入匯出資料測試SQL
- 樣式字型測試使用
- 建立和測試分類器使用者定義函式函式
- 第2章 編寫測試函式函式
- MySQL字元函式的壓力測試MySql字元函式
- 測試建立基於函式的索引函式索引
- ORACLE FUNCTION函式中DETERMINISTIC測試OracleFunction函式
- 測開之函式進階· 第1篇《遞迴函式》函式遞迴
- Golang時間函式及測試函式執行時間案例Golang函式
- pytest標記:查詢測試策略、標記測試函式函式
- 嘗試使用 pack 與 unpack 函式函式
- SQLLDR直接載入幾個引數的測試SQL
- sqlldr使用SQL
- 管道函式及表函式的測試PIPELINED__PIPE ROW函式
- VC程式執行時間測試函式C程式函式
- 函式1函式
- 說說在 Python 中如何測試函式Python函式
- Linux常用C函式—字元測試篇(轉)Linux函式字元
- C++ 虛解構函式簡單測試C++函式
- 測試1
- sqlldr的使用SQL