測試TOM=SQLLDR使用函式載入資料

oracle_db發表於2012-05-14
要在SQLLDR指令碼中向某列應用函式,只需要將這個函式增加到控制檔案中,用兩引號括起來。

測試如下

[oracle@oraclelinux ~]$ cat dept_load10.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'
)
BEGINDATA
10,Sales,Virginia,1/5/2000
20,Accounting,Virginia,21/6/1999
30,Consulting,Virginia,5/1/2000
40,consulting,virginia,5/1/2000
[oracle@oraclelinux ~]$ sqlldr userid=scott/scott control=dept_load10.ctl

SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 14 12:31:10 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                                    01-MAY-00
        20 ACCOUNTING     VIRGINIA                                    21-JUN-99
        30 CONSULTING     VIRGINIA                                    05-JAN-00
        40 CONSULTING     VIRGINIA                                    05-JAN-00

SQL> 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15720542/viewspace-723498/,如需轉載,請註明出處,否則將追究法律責任。

相關文章