2017-03-26 75 views
0

我是使用SQL的新手,所以我很抱歉,如果這是一個簡單的錯誤。基本上我需要將一些數據加載到表中。但是,當我嘗試使用sql loader將數據插入到表中時,它並未插入,但沒有錯誤顯示出現任何錯誤。SQL Loader沒有插入數據

表:

create table Test(var char(3), var2 char(10), var3 number(7,2), 
var4 char(3),primary key (var)); 

這是我的控制文件(Test1.ctl):

LOAD DATA 
INFILE * 
REPLACE INTO TABLE Test 
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY "'" TRAILING NULLCOLS 
(var, var2, var3, var4 terminated by whitespace) 
BEGINDATA 
'123','test',12345,'321' 
'321','test2',54321,null 

我使用一個單獨的.csv文件來加載數據,而不是BEGINDATA也試過,但兩種方法都會發生同樣的事情。

基本上從當我嘗試加載數據的命令提示符下,出現這種情況:

[******** ~]$ sqlldr user_name Test1.ctl 
Password:****** 

SQL*Loader: Release 10.2.0.3.0 - Production on Sun Mar 26 14:01:21 2017 

[******** ~]$ 

然後,當我去到在sqlplus檢查表,它是空的。

SQL> desc Test; 
Name          Null? Type 
----------------------------------------- -------- ------------------------- 
VAR          NOT NULL CHAR(3) 
VAR2            CHAR(10) 
VAR3            NUMBER(7,2) 
VAR4            CHAR(3) 

SQL> select * from Test; 

no rows selected 

SQL> 

我不明白爲什麼它不會加載到表中。

感謝您的幫助!

+0

請顯示日誌文件 –

回答

0

版本10是一個很老的版本!

我不能在12c中重現您的問題。你應該加載一行;第二行失敗,因爲它試圖將4個字符的字符串「null」加載到CHAR中(3)

sqlldr scott test1.ctl 
Password: 

SQL*Loader: Release 12.1.0.2.0 - Production on Mon Mar 27 10:04:06 2017 

Copyright (c) 1982, 2015, Oracle and/or its affiliates. All rights reserved. 

Path used:  Conventional 
Commit point reached - logical record count 2 

Table TEST: 
    1 Row successfully loaded. 

Check the log file: 
    test1.log 
for more information about the load. 


cat test1.log 

SQL*Loader: Release 12.1.0.2.0 - Production on Mon Mar 27 10:04:06 2017 

Copyright (c) 1982, 2015, Oracle and/or its affiliates. All rights reserved. 

Control File: test1.ctl 
Data File:  test1.ctl 
    Bad File:  test1.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 TEST, loaded from every logical record. 
Insert option in effect for this table: REPLACE 
TRAILING NULLCOLS option in effect 

    Column Name     Position Len Term Encl Datatype 
------------------------------ ---------- ----- ---- ---- --------------------- 
VAR         FIRST  * , O(') CHARACTER    
VAR2         NEXT  * , O(') CHARACTER    
VAR3         NEXT  * , O(') CHARACTER    
VAR4         NEXT  * WHT O(') CHARACTER    

Record 2: Rejected - Error on table TEST, column VAR4. 
ORA-12899: value too large for column "SCOTT"."TEST"."VAR4" (actual: 4, maximum: 3) 


Table TEST: 
    1 Row successfully loaded. 
    1 Row 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:     66048 bytes(64 rows) 
Read buffer bytes: 1048576 

Total logical records skipped:   0 
Total logical records read:    2 
Total logical records rejected:   1 
Total logical records discarded:  0 

Run began on Mon Mar 27 10:04:06 2017 
Run ended on Mon Mar 27 10:04:08 2017 

Elapsed time was:  00:00:02.68 
CPU time was:   00:00:00.03