sqlldr 匯入資料範例

wuyuanyong發表於2010-06-29

一、具體資料如下要匯入到aa表中phonenum,status,create_time,fee欄位中,由於id欄位是主鍵所以該欄位不能為空值因此也要匯入相應的值,本例中id 欄位直接匯入序列值

13858000000,2,2009-5-15 14:55:04,835
13868000000,1,2009-5-22 10:39:04,84
13958000000,1,2009-6-16 17:31:08,59
13456640000,1,2008-7-28 21:45:53,37
13505710000,1,2009-5-20 11:37:45,365
13505720000,1,2009-5-20 11:38:37,65
13505800000,1,2009-5-20 11:41:08,12
13505810000,1,2009-5-20 11:41:42,13
13505840000,1,2009-5-20 11:42:19,246
13506550000,1,2008-10-23 0:59:18,108
13506810000,1,2009-5-20 11:47:43,400
13516720000,1,2009-8-19 18:30:50,98
13566030000,1,2008-8-9 7:05:03,113
13566130000,1,2009-10-16 10:04:00,14
13566220000,1,2008-11-14 14:13:25,14
13566230000,1,2008-11-15 7:43:32,204
13566320000,1,2008-8-9 8:37:21,285
13566350000,1,2008-8-9 9:07:10,28

二、aa表結構如下:

Name Null? Type
--------------------- -------- ----------------------------
ID NOT NULL NUMBER
PHONENUM VARCHAR2(20)
CF NUMBER
CREATE_TIME DATE
MSG VARCHAR2(150)
ICPNO VARCHAR2(20)
STATUS NUMBER
QUIT_TIME DATE
BUSI_TYPE VARCHAR2(20)
FEE NUMBER
FLAG NUMBER(5)
SUBTYPE NUMBER
UNSUBTYPE NUMBER
MEMO VARCHAR2(100)
AREA VARCHAR2(10)

三、建立匯入資料的控制檔案:

vi zzy.ctl

load data
infile '/data/12.txt'
append into table aa
fields terminated by ','
trailing nullcols
(id sequence(87,1),phonenum,status,create_time date "yyyy-mm-dd hh24:mi:ss",fee terminated by whitespace)

四、具體匯入的命令:
sqlldr username/paasswd control=zzy.ctl direct=true

[@more@]

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

相關文章