Binary strings

A binary string is a sequence of bytes. Unlike character strings, which usually contain text data, binary strings are used to hold data such as pictures, voice, or mixed media.

Binary strings are not associated with a code page; their code page value is 0. The length of a binary string is the number of bytes it contains. Only character strings of the FOR BIT DATA subtype are compatible with binary strings.

The unit of length for the binary string data type is OCTETS and cannot be explicitly specified.

Fixed-length binary string

A fixed-length binary string has the data type BINARY. All values in a fixed-length string column have the same length, which is determined by the length attribute of the data type. The length attribute must be in the range 1 - 255, inclusive.

Varying-length binary strings

There are two types of varying-length binary string:
A VARBINARY value can be up to 32,672 bytes long.
A binary large object (BLOB) value can be up to 2 gigabytes minus 1 byte (2,147,483,647 bytes) long. A BLOB can hold structured data for exploitation by user-defined types and user-defined functions.

Special restrictions apply to an expression that results in a BLOB data type. These restrictions are the same as the restrictions described in Varying-length character strings.