2016-04-12 45 views
2

我想使用Teradata的Fastload腳本將我的CSV文件導入Teradata。 我也嘗試添加一個自動增量列。 這是我的CSV文件:Teradata創建表自動增加列錯誤

Word,country,sale,week 
hi,USA,26.17,11/22/15-11/28/15 
bye,USA,16.5,11/22/15-11/28/15 

代碼片段

String tableName = "my_db.mytable"; 
    String createTable = "CREATE TABLE " + tableName + "," + 
          "NO FALLBACK," + 
          "NO BEFORE JOURNAL," + 
          "NO AFTER JOURNAL," + 
          "CHECKSUM = DEFAULT" + 
          "(" + 
          " id decimal(10,0) NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 NO CYCLE),"+ 
          " word VARCHAR(500) CHARACTER SET UNICODE," + 
          " country VARCHAR(50)," + 
          " sale FLOAT," + 
          " week VARCHAR(30)" + 
          ") " + 
          "PRIMARY INDEX (id)"; 

    // INSERT statement 
    String insertTable = "INSERT INTO " + tableName + " VALUES(?,?,?,?,?)"; 

錯誤,我得到:

Row 1 in FastLoad table my_db.mytable_ERR_1 contains the following data: 
ErrorCode=2673 
ErrorFieldName=F_id 
ActualDataParcelLength=55 
DataParcel: byte array length 55 (0x37), offset 0 (0x0), dump length 55 (0x37) 

回答

0

這看起來並不像一個FastLoad腳本,是一個JDBC的這部分-FastLoad?

2673源宗地長度與所定義的數據不匹配。

您的輸入數據是以逗號分隔的文本,因此您必須將所有列定義爲VARCHAR。

而且還有在輸入文件列,但您在INSERT指定。顧名思義一個GENERATED ALWAYS序列是自動創建的。