skip to main content
Querying data stores with SQL : Supported data types : DB2 data types
  

Try Now

DB2 data types

The following table shows how the DB2 data types are mapped to the standard data types for ODBC and JDBC.
Note: When the EnableWCharSupport connection parameter is set to true for the Hybrid Data Pipeline Driver for ODBC, character types are mapped to the corresponding ODBC W-Types. For example, the varchar(max) type is mapped to the Unicode type SQL_WLONGVARCHAR.
Table 154. DB2 data types
DB2 data type
JDBC data type
ODBC data type
BIGINT 1
BIGINT
SQL_BIGINT(-5)
BINARY 2
BINARY
SQL_BINARY(-2)
BLOB 3
BLOB
SQL_LONGVARBINARY(-4)
CHAR
CHAR
SQL_WCHAR(-8) or SQL_CHAR(1)
CHAR() FOR BIT DATA
BINARY
SQL_BINARY(-2)
CLOB
CLOB
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)
DATE
DATE or TIMESTAMP 4
SQL_TYPE_DATE(91) or SQL_TYPE_TIMESTAMP(93)
DBCLOB
CLOB or NCLOB 5
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)
DECFLOAT
DECIMAL
SQL_DECIMAL(3)
DECIMAL
DECIMAL
SQL_DECIMAL(3)
DOUBLE
DOUBLE
SQL_DOUBLE(8)
FLOAT
FLOAT
SQL_FLOAT(6)
GRAPHIC
CLOB or NCLOB
SQL_WCHAR(-8) or SQL_CHAR(1)
INTEGER
INTEGER
SQL_INTEGER(4)
LONG VARCHAR
LONGVARCHAR
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)
LONG VARCHAR FOR BIT DATA
LONGVARBINARY
SQL_LONGVARBINARY(-4)
LONG VARGRAPHIC
LONGVARCHAR or LONGNVARCHAR 6
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)
NUMERIC
NUMERIC
SQL_NUMERIC(2)
REAL
REAL
SQL_REAL(7)
ROWID
VARBINARY
SQL_VARBINARY(-3)
SMALLINT
SMALLINT
SQL_SMALLINT(5)
TIME
TIME
SQL_TYPE_TIME(92)
TIMESTAMP
TIMESTAMP
SQL_TYPE_TIMESTAMP(93)
VARCHAR() FOR BIT DATA
VARBINARY
SQL_VARBINARY(-4)
TIMESTAMP WITH TIMEZONE
TIMESTAMP or VARCHAR
SQL_TYPE_TIMESTAMP(93) or SQL_WVARCHAR(-9) or SQL_VARCHAR(12)
VARBINARY
VARBINARY
SQL_VARBINARY(-3)
VARCHAR
VARCHAR
SQL_WVARCHAR(-9) or SQL_VARCHAR(12)
VARGRAPHIC
VARCHAR or NVARCHAR 7
SQL_WVARCHAR(-9) or SQL_VARCHAR(12)
XML
CLOB or SQLXML
SQL_WLONGVARCHAR(-10) or SQL_LONGVARCHAR(-1)

1 Supported only for DB2 V9.1 for z/OS.

2 Supported only for DB2 V9.1 for z/OS.

3 Supported only for DB2 V8.1 and higher for Linux/UNIX/Windows, DB2 for z/OS, and DB2 for i V5R2.

4 For DB2 V9.7 for Linux/UNIX/Windows with the Oracle compatibility feature enabled, the Date type maps to the JDBC TIMESTAMP type.

5 When JDBCBehavior=0, the data type depends on the JVM used by the application. For JVMs earlier than Java SE 6, the first value applies. For Java SE 6 and higher, the second value applies.

6 When JDBCBehavior=0, the data type depends on the JVM used by the application. For JVMs earlier than Java SE 6, the first value applies. For Java SE 6 and higher, the second value applies.

7 When JDBCBehavior=0, the data type depends on the JVM used by the application. For JVMs earlier than Java SE 6, the first value applies. For Java SE 6 and higher, the second value applies.