SQL-J Language Reference
Page 91 of 121

BIT VARYING

The BIT VARYING field allows you to store bit strings of a specified length. Like the BIT data type, it is useful for unstructured data where character strings are not appropriate (e.g., images).

Syntax for Column Definition

BIT VARYING (length)

length is an unsigned integer literal designating the length in bits.

Unlike the case for the BIT data type, there is no default length for a BIT VARYING type.

Corresponding Compile-Time Java Type

byte[]

JDBC Metadata Type (java.sql.Types)

BINARY

BIT VARYING stores variable-length bit strings. Unlike BIT values, BIT VARYING values are not padded out to the target length. If a BIT VARYING value is larger than the target length, a bit right truncation exception is raised.

Comparisons of BIT and BIT VARYING values are precise. For two bit strings to be equal, they must be exactly the same length. (This differs from the way some other DBMSs handle BINARY values but works as specified in SQL-92.)

An operation on a BIT VARYING and a BIT value (e.g., a concatenation) yields a BIT VARYING value.

BIT VARYING Literal Examples

The type of a bit literal is always a BIT, not a BIT VARYING.

Implementation-Defined Aspects

The only limit on the length of BIT and BIT VARYING data types is the constraint of the integer used to specify the length, the value java.lang.Integer.MAX_VALUE.