Db2

用於載入語句的 Db2 時間戳格式

  • July 29, 2016

我有一個帶有時間戳的文件,如 20130807183000000。我正在嘗試使用 timestampformat=“YYYYMMDDHHMMSSUUU” 載入,但出現錯誤

SQL0181N 日期時間值的字元串表示超出範圍。

我很確定問題在於 db2 將分鐘解釋為月份。我一直找不到任何有關如何將其顯式格式化為載入語句的一分鐘的文件。我嘗試使用“MI”,因為它適用於 timestamp_format 函式,但沒有運氣。有誰知道任何隱藏的文件或有任何不涉及編輯文件的建議?謝謝。

那應該行得通。我創建了一個文件,如:

[lelle@dustbite src]$ cat apa.csv 
20130807183000000

和一個像這樣的表:

[lelle@dustbite src]$ db2 "create table tt (ts timestamp not null)"

並載入如下:

[lelle@dustbite src]$ db2 "load from apa.csv of del modified by timestampformat=\"YYYYMMDDHHMMSSUUU\" insert into tt"
SQL3501W  The table space(s) in which the table resides will not be placed in 
backup pending state since forward recovery is disabled for the database.

SQL3109N  The utility is beginning to load data from file 
"/home/lelle/src/apa.csv".

SQL3500W  The utility is beginning the "LOAD" phase at time "07/29/2016 
20:35:42.233607".

SQL3519W  Begin Load Consistency Point. Input record count = "0".

SQL3520W  Load Consistency Point was successful.

SQL3110N  The utility has completed processing.  "1" rows were read from the 
input file.

SQL3519W  Begin Load Consistency Point. Input record count = "1".

SQL3520W  Load Consistency Point was successful.

SQL3515W  The utility has finished the "LOAD" phase at time "07/29/2016 
20:35:42.482947".


Number of rows read         = 1
Number of rows skipped      = 0
Number of rows loaded       = 1
Number of rows rejected     = 0
Number of rows deleted      = 0
Number of rows committed    = 1

這可能是您沒有引用 " 以便外殼擺脫那些的原因嗎?

如果我做:

[lelle@dustbite src]$ db2 "load from apa.csv of del modified by timestampformat="YYYYMMDDHHMMSSUUU" insert into tt"

我得到錯誤:

SQL3192N  In the filetmod a user specified format "TIMESTAMPFORMAT" beginning with the string "YYYYMMDDHHMMSSUUU" is not valid.

如果這不是問題,您能否提供一小部分在載入期間失敗的行樣本?

引用自:https://dba.stackexchange.com/questions/145375