读书人

DB2导出其后导入后-数据少了-为啥

发布时间: 2012-12-29 10:28:09 作者: rapoo

DB2导出然后导入后-数据少了-为啥
大家好,在这里向你们请教一个问题。

有一个A表,里面有140W的数据,现在对部分 ‘过期’ 数据要做备份,我将它分成两部分导出,一部分是过期的(old),一部分是要继续留下的(new)
因为考虑到方便,在清表后,将"一部分是要继续留下的(new)"数据重新Load进表里。
首先:
<code>
export to td_fm_unites_20110531_olddata.txt of del select * from tbl where time<'20110531';
export to td_fm_unites_20110531_newdata.txt of del select * from tbl where time>'20110531';
</code>
Export完成后,
<code>
[db2inst1@itcc db2databak]$ wc -l td_fm_unites_20110531_newdata.txt
939817 td_fm_unites_20110531_newdata.txt
[db2inst1@itcc db2databak]$ wc -l td_fm_unites_20110531_olddata.txt
457457 td_fm_unites_20110531_olddata.txt
</code>
然后, 我创建一个空文件 del.del
<code>
load from del.del of del
insert into tbl;
<code>
将 tbl表里面的数据清空。

此时,将td_fm_unites_20110531_newdata的数据Load到表里

load from td_fm_unites_20110531_newdata.txt of del
insert into tbl;

但是Load后,发现数据少了很多。


db2 => load from td_fm_unites_20110531_newdata.txt of del
db2 (cont.) => insert into td_fm_unites;
load from td_fm_unites_20110531_newdata.txt of del insert into td_fm_unites
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/db2inst1/db2databak/td_fm_unites_20110531_newdata.txt".

SQL3500W The utility is beginning the "LOAD" phase at time "2012-05-31
15:39:30.315169".

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

SQL3520W Load Consistency Point was successful.

SQL3125W The character data in row "F2-25908" and column "1" was truncated
because the data is longer than the target database column.

SQL3119W The field value in row "F2-25909" and column "4" cannot be converted
to an INTEGER value. A null was loaded.

SQL3119W The field value in row "F2-25909" and column "5" cannot be converted
to an INTEGER value. A null was loaded.

SQL0180N The syntax of the string representation of a datetime value is
incorrect. SQLSTATE=22007

SQL3185W The previous error occurred while processing data from row
"F2-25909" of the input file.

SQL3125W The character data in row "F1-26018" and column "1" was truncated
because the data is longer than the target database column.

SQL3119W The field value in row "F1-26019" and column "4" cannot be converted
to an INTEGER value. A null was loaded.



SQL3119W The field value in row "F1-26019" and column "5" cannot be converted
to an INTEGER value. A null was loaded.

SQL0180N The syntax of the string representation of a datetime value is
incorrect. SQLSTATE=22007

SQL3185W The previous error occurred while processing data from row
"F1-26019" of the input file.

SQL3125W The character data in row "F2-26003" and column "1" was truncated
because the data is longer than the target database column.

SQL3125W The character data in row "F1-26058" and column "1" was truncated
because the data is longer than the target database column.

SQL3119W The field value in row "F1-26059" and column "4" cannot be converted
to an INTEGER value. A null was loaded.

SQL3119W The field value in row "F1-26059" and column "5" cannot be converted
to an INTEGER value. A null was loaded.

SQL0180N The syntax of the string representation of a datetime value is
incorrect. SQLSTATE=22007

SQL3185W The previous error occurred while processing data from row
"F1-26059" of the input file.

SQL3119W The field value in row "F2-26004" and column "4" cannot be converted
to an INTEGER value. A null was loaded.

SQL3119W The field value in row "F2-26004" and column "5" cannot be converted
to an INTEGER value. A null was loaded.

SQL0180N The syntax of the string representation of a datetime value is
incorrect. SQLSTATE=22007

SQL3185W The previous error occurred while processing data from row
"F2-26004" of the input file.

SQL3125W The character data in row "F2-26103" and column "1" was truncated
because the data is longer than the target database column.

SQL3119W The field value in row "F2-26104" and column "4" cannot be converted
to an INTEGER value. A null was loaded.

SQL3119W The field value in row "F2-26104" and column "5" cannot be converted
to an INTEGER value. A null was loaded.

SQL0180N The syntax of the string representation of a datetime value is
incorrect. SQLSTATE=22007

SQL3185W The previous error occurred while processing data from row
"F2-26104" of the input file.



SQL3125W The character data in row "F0-26331" and column "1" was truncated
because the data is longer than the target database column.

SQL3227W Record token "F1-26018" refers to user record number "103822".

SQL3119W The field value in row "F0-26332" and column "4" cannot be converted
to an INTEGER value. A null was loaded.

SQL3227W Record token "F1-26019" refers to user record number "103823".

SQL3119W The field value in row "F0-26332" and column "5" cannot be converted
to an INTEGER value. A null was loaded.

SQL3227W Record token "F1-26058" refers to user record number "103862".

SQL0180N The syntax of the string representation of a datetime value is
incorrect. SQLSTATE=22007

SQL3227W Record token "F1-26059" refers to user record number "103863".

SQL3185W The previous error occurred while processing data from row
"F0-26332" of the input file.

SQL3227W Record token "F2-25908" refers to user record number "103896".

SQL3227W Record token "F2-25909" refers to user record number "103897".

SQL3227W Record token "F2-26003" refers to user record number "103991".

SQL3227W Record token "F2-26004" refers to user record number "103992".

SQL3227W Record token "F2-26103" refers to user record number "104091".

SQL3227W Record token "F2-26104" refers to user record number "104092".

SQL3227W Record token "F0-26331" refers to user record number "105018".

SQL3227W Record token "F0-26332" refers to user record number "105019".

SQL3125W The character data in row "F0-32057" and column "1" was truncated
because the data is longer than the target database column.

SQL3119W The field value in row "F0-32058" and column "4" cannot be converted
to an INTEGER value. A null was loaded.

SQL3119W The field value in row "F0-32058" and column "5" cannot be converted
to an INTEGER value. A null was loaded.

SQL0180N The syntax of the string representation of a datetime value is
incorrect. SQLSTATE=22007

SQL3185W The previous error occurred while processing data from row
"F0-32058" of the input file.

SQL3227W Record token "F0-32057" refers to user record number "127637".

SQL3227W Record token "F0-32058" refers to user record number "127638".



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

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

SQL3520W Load Consistency Point was successful.

SQL3515W The utility has finished the "LOAD" phase at time "2012-05-31
15:39:38.098329".

SQL3500W The utility is beginning the "BUILD" phase at time "2012-05-31
15:39:38.100953".

SQL3213I The indexing mode is "REBUILD".

SQL3515W The utility has finished the "BUILD" phase at time "2012-05-31
15:39:46.563448".

SQL3500W The utility is beginning the "DELETE" phase at time "2012-05-31
15:39:46.741632".

SQL3509W The utility has deleted "165096" rows from the table.

SQL3515W The utility has finished the "DELETE" phase at time "2012-05-31
15:39:56.147447".

SQL3107W There is at least one warning message in the message file.


Number of rows read = 939817
Number of rows skipped = 0
Number of rows loaded = 939810
Number of rows rejected = 7
Number of rows deleted = 165096
Number of rows committed = 939817
[解决办法]
首先 load from del.del of del insert into tbl; 不会清空表的数据(insert into是追加),
清空表的数据可以用 db2 load from /dev/null of del replace into tbl。
db2 9.7以后的版本可以用db2 truncat table tbl immediate。

你的表数据是不是有不可见的字符,laod的时候最好加上 modified by delprioritychar usedefaults
参数,会屏蔽不可见字符中的“,”、“回车”等。


[解决办法]
Number of rows read = 939817
Number of rows skipped = 0
Number of rows loaded = 939810
Number of rows rejected = 7 (没有插入,根据上面的提示是,不是int型数据,数据长度不对,可能是含有不可见的字符造成)
Number of rows deleted = 165096 (违反唯一索引,被删除,可能是你之前清空不成功造成)
Number of rows committed = 939817
[解决办法]

引用:
Number of rows read = 939817
Number of rows skipped = 0
Number of rows loaded = 939810
Number of rows rejected = 7 (没有插入,根据上面的提示是,不是int型数据,数据长度不对,可能是含有不可见的字符造成)
Number of rows deleted = 165096 (违反……

[db2inst1@itcc db2databak]$ wc -l td_fm_unites_20110531_newdata.txt
939817 td_fm_unites_20110531_newdata.txt

根据上面的提示,应该是都插进去了吧

读书人网 >IBM DB2

热点推荐