Output field types

An output field can have a different data type from the one that is defined on a source table column if the data types are compatible. The UNLOAD utility follows the general Db2 rules and conventions for the data type attributes and the compatibility among the data types.

If you specify a data type in the UNLOAD control statement, the field type information is included in the generated LOAD utility statement. For specific data type compatibility information, refer to the following table. These tables show the compatibility of the data type of the source column (input data type) with the data type of the output field (output data type). A Y indicates that the input data type can be converted to the output data type.

The following table shows the compatibility of converting numeric data types.

Table 1. Compatibility of converting numeric data types
Input data types Output data types
SMALLINT INTEGER (external) BIGINT DECIMAL (external) FLOAT (external) DOUBLE or REAL FLOAT/REAL
SMALLINT Y Y1 Y Y1 Y1 Y Y
INTEGER Y2 Y1 Y Y1 Y1 Y Y
BIGINT Y2 Y2 Y2 Y Y N Y
DECIMAL Y2 Y1, 2 Y2 Y1 Y1 Y Y
FLOAT, DOUBLE, or REAL Y2 Y1, 2 Y2 Y1, 2 Y1 Y Y
DECFLOAT Y2 Y1, 2 Y2 Y1, 2 Y1, 2 N2 Y3
Note:
  1. Subject to the CCSID conversion, if specified (EXTERNAL case).
  2. Potential overflow (conversion error).
  3. When converting from DECFLOAT(34) to DECFLOAT(16), you might encounter overflow, underflow, subnormal number, or inexact. However, there will be no conversion error.

The following table shows the compatibility of converting character data types.

Table 2. Compatibility of converting character data types
Input data types Output data types
BLOB CHAR
VAR-
CHAR
CLOB GRAPHIC
GRAPHIC
EXTER-
NAL
VAR-
GRAPHIC
DB-
CLOB
BINARY
VAR-
BINARY
BLOB Y N N N N N N N N N
CLOB N Y1, 2 Y1, 2 Y N N N N N N
DBCLOB N N N N Y1, 2 Y1, 2, 3 Y1, 2 Y1 N N
CHAR N Y1 Y1 Y1, 4 N N N N Y Y
VARCHAR
or
LONG
VARCHAR
N Y1,2 Y1 Y1, 4 N N N N Y Y
GRAPHIC N N N N Y1 Y1, 3 Y1 Y1 N N
VAR-
GRAPHIC or
LONG VAR-
GRAPHIC
N N N N Y1, 2 Y1, 2, 3 Y1 Y1 N N
BINARY Y N N N N N N N Y Y
VARBINARY Y N N N N N N N Y Y
Note:
  1. Subject to the CCSID conversion, if specified.
  2. Results in an error if the field length is too small for the data unless you specify the TRUNCATE option. Note that a LOB has a 4-byte length field; any other varying-length type has a 2-byte length field.
  3. Only in the EBCDIC output mode.
  4. Not applicable to BIT subtype data.

The following table shows the compatibility of converting time data types.

Table 3. Compatibility of converting time data types
Input data types Output data types
DATE EXTERNAL TIME EXTERNAL TIMESTAMP EXTERNAL TIMESTAMP WITH TIME ZONE EXTERNAL
DATE Y1 N Y1, 2 Y1,2
TIME N Y1 N N
TIMESTAMP Y1, 3 Y1, 3 Y1 Y1,2
TIMESTAMP WITH TIME ZONE Y1,4 Y1,4 Y1,4 Y1
Note:
  1. Subject to the CCSID conversion, if specified.
  2. Zeros in the time portion. IMPLICIT_TZ in time zone portion if the output data type is TIMESTAMP WITH TIME ZONE.
  3. DATE or TIME portion of the timestamp.
  4. DATE, TIME or TIMESTAMP portion of the timestamp with time zone.