Binary data types

The binary18 and binaryvar data types allow user to store binary-encoded strings which can be indexed for quick retrieval.

You can use string manipulation functions to validate the data types and bitwise operation functions that allow you to perform bitwise logical AND, OR, XOR comparisons or apply a bitwise logical NOT to a string.

Since the binary data types are unstructured types, they can store many different types of information, for example, IP addresses, MAC addresses, or device identification numbers from RFID tags. The binary data types can also store encrypted data in binary format, which saves disk space. Instead of storing an IP address like xxx.xxx.xxx.xxx as a CHAR(15) data type, you can store it as a binaryvar data type, which uses only 6 bytes.

You can store and index binary data by using the binaryvar and binary18 data types.

Binaryvar data type

The binaryvar data type is a variable-length opaque type with a maximum length of 255 bytes.

Binary18 data type

The binary18 data type is a fixed-length opaque data type that holds 18 bytes. Input strings shorter than 18 bytes are right padded with zeros (00). Strings longer than 18 bytes are truncated.

The binary18 data type has the advantage of not having its length stored as part of the byte stream. When inserting data into the binaryvar data type, the first byte must be the length of the byte array. The binary18 data type does not have this restriction.