Metadata for columns that are defined in code units

The java.sql.DatabaseMetaData methods provide information about table columns that are defined with code units.

Db2® on Linux®, UNIX, and Windows systems Version 10.5 or later supports character or graphic column definitions that have the OCTETS, CODEUNITS16, or CODEUNITS32 length attribute. That attribute indicates whether the column or parameter length is defined as single bytes, UTF-16 units (two-byte units), or UTF-32 units (four-byte units).

For example, in the following table definition, the length of the first column is in bytes, the length of the second column is in two-byte units, and the length of the third column is in four-byte units:

CREATE TABLE MYTABLE (
 COL1 CHAR(10 OCTETS),
 COL2 GRAPHIC(10 CODEUNITS16),
 COL3 VARCHAR(10 CODEUNITS32));

The standard JDBC java.sql.DatabaseMetaData methods return information about lengths of the columns in bytes and code units. That information is summarized in the following table.

Method Length and code unit information returned
java.sql.DatabaseMetaData.getColumns
COLUMN_SIZE result set column
Length in code units
CHAR_OCTET_LENGTH result set column
Length in bytes
java.sql.DatabaseMetaData.getProcedureColumns
LENGTH result set column
Length in bytes
PRECISION result set column
Length in code units
CHAR_OCTET_LENGTH result set column
Length in bytes
java.sql.DatabaseMetaData.getAttributes
ATTR_SIZE result set column
Length in code units
CHAR_OCTET_LENGTH result set column
Length in bytes
java.sql.DatabaseMetaData.getFunctionColumns
LENGTH result set column
Length in bytes
PRECISION result set column
Length in code units
CHAR_OCTET_LENGTH result set column
Length in bytes
java.sql.DatabaseMetaData.getTypeInfo
PRECISION result set column
Length in code units