Data Types
- Last Updated: March 29, 2022
- 1 minute read
- DataDirect Connectors
- ODBC
- IBM Db2 8.0
- Documentation
The following table shows how the Db2 data types map to the standard ODBC data types. Unicode support in Driver specifications lists Db2 to Unicode data type mappings.
| Db2 | ODBC |
|---|---|
| Bigint1 | SQL_BIGINT |
| Binary | SQL_BINARY |
| 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 |
| Varbinary | SQL_VARBINARY |
| 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.