IBM Support

[Db2] EXPORT コマンドの SQL3132W によるデータ切り捨て

Question & Answer


Question

EXPORT を実行したところ SQL3132W が返りました。
実際に EXPORT されたデータを確認しましたがデータの切り捨ては発生していませんでした。
理由を教えてください。

Cause

EXPORT は対象のカラムのデータ長をチェックし、EXPORT がサポートするデータの最大長により切り捨てが発生する可能性があるときに SQL3132 Wを出力します。カラム内のデータが最大長に達しない場合、実際の切り捨ては発生しません。
切り捨てが実際に発生したかどうかは SQL0445W で確認できます。

Answer

以下の例をご参照ください。
例:
table1 表の C2 列には各種長さのデータが格納されています。
$ db2 "select c1, length(c2) from table1"
C1          2
----------- -----------
          1           2
          2           4
          3           8
          4          16
          5          32
          6          64
          7         128
          8         256
          9         512
         10        1024
         11        2048
         12        4096
         13        8192
         14       16384
         15       32768
         16       65536
         17      131072
         18      262144
         19      524288
         20     1048576
         21     2097152
         22     4194304
         23     8388608
         24    16777216
         25    33554432
         26    67108864
         27   134217728
         28   268435456
         29   536870912
         30  1073741824
  30 record(s) selected.
ケース1:SQL3132Wが表示され、切捨てが発生する。
C1=15のC2のデータ長=32768のデータをEXPORT
$ db2 "export to test.csv of del select varchar(c2, 32672) from table1 where c1 = 15"
                <
SQL3132W  The character data in column "1" will be truncated to size "32700".
SQL3104N  The Export utility is beginning to export data to file "test.csv".
SQL3015N  An SQL error "445" occurred during processing.
SQL0445W  Value
"あああああああああああああああああああああああ" has
been truncated.  SQLSTATE=01004
SQL3105N  The Export utility has finished exporting "1" rows.

Number of rows exported: 1
ケース2:SQL3132Wが表示されるが、切り捨ては発生しない。
C1=1のC2のデータ長=2のデータをEXPORT
$ db2 "export to test.csv of del select varchar(c2, 32672) from table1 where c1 = 1"
SQL3132W  The character data in column "1" will be truncated to size "32700".
SQL3104N  The Export utility is beginning to export data to file "test.csv".
SQL3105N  The Export utility has finished exporting "1" rows.

Number of rows exported: 1
ケース3: SQL3132Wは表示さないが切り捨てが発生する。
関数(このケースではVARCHAR)の結果の長さは、EXPORTで事前検証しないのでSQL3132Wは、出力されません。
$ db2 "export to test.csv of del select varchar(c2, 10900) from table1 where c1 = 18"
SQL3104N  The Export utility is beginning to export data to file "test.csv".
SQL3015N  An SQL error "445" occurred during processing.
SQL0445W  Value
"あああああああああああああああああああああああ" has
been truncated.  SQLSTATE=01004
SQL3105N  The Export utility has finished exporting "1" rows.

Number of rows exported: 1

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"ARM Category":[{"code":"a8m500000008PlGAAU","label":"Data Movement-\u003EExport"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"10.1.0;10.5.0;11.5.0"}]

Document Information

Modified date:
05 December 2022

UID

ibm11125855