skip to main content
Part 2: The 32-Bit/64-Bit Drivers : The DB2 Wire Protocol Driver : Data Types
  
Data Types
The following table shows how the DB2 data types map to the standard ODBC data types. Unicode Support lists DB2 to Unicode data type mappings.
Table 16. DB2 Data Types
DB2
ODBC
Bigint1
SQL_BIGINT
Blob2
SQL_LONGVARBINARY
Char
SQL_CHAR
Char() for Bit Data
SQL_BINARY
Clob3
SQL_LONGVARCHAR
Date
SQL_TYPE_DATE
Decfloat4
SQL_DOUBLE
Decimal
SQL_DECIMAL
Double
SQL_DOUBLE
Float
SQL_DOUBLE
Integer
SQL_INTEGER
Long Varchar
SQL_LONGVARCHAR
Long Varchar for Bit Data
SQL_LONGVARBINARY
Numeric
SQL_NUMERIC
Real
SQL_REAL
Smallint
SQL_SMALLINT
Time
SQL_TYPE_TIME
Timestamp5
SQL_TYPE_TIMESTAMP
Timestamp With Time Zone6, 7
SQL_VARCHAR
Varchar
SQL_VARCHAR
Varchar() for Bit Data
SQL_VARBINARY
XML8
SQL_LONGVARCHAR

1 Supported on DB2 V8.x and higher for Linux/UNIX/Windows, DB2 V9 and higher for DB2 for z/OS, and DB2 V5R3 and higher for DB2 for i.

2 Supported on DB2 V8.x and higher for Linux/UNIX/Windows; DB2 for z/OS; and DB2 V5R3 and higher for DB2 for i.

3 On DB2 for Linux/UNIX/Windows versions previous to V8.1 and DB2 V5R2 for DB2 for i, only the first 32 KB of the Clob data are returned when fetching, and only 32 KB can be inserted and updated.

4 Supported only on DB2 V9 and higher for Linux/UNIX/Windows, DB2 V9 and higher for DB2 for z/OS, and DB2 i V6R1 for DB2 for i.

5 Timestamp values with a fractional seconds precision greater than 9 are described as the ODBC SQL_VARCHAR data type.

6 Supported on DB2 V8.x and higher for Linux/UNIX/Windows; DB2 for z/OS; and DB2 V5R3 and higher for DB2 for i.

7 Timestamp with Time Zone mapping changes based on the setting of the FetchTSWTZasTimestamp option only on DB2 V10 and higher for DB2 for z/OS.

8 Supported only on DB2 V10 for z/OS.

See Retrieving Data Type Information for information about retrieving data types.
* Using the XML Data Type