Skip to main content

BYTEARRAY

This function is used to cast data to the BYTEARRAY data type.

Syntax

BYTEARRAY ( arg )  

arg
The value to be cast. The value can be any data type and its byte representation is determined by how the value is written to data pages.

Return Value

Returns the BYTEARRAY representation of the value provided.

Examples

This returns the byte representation of the UINT64 1.

SELECT BYTE_ARRAY(1);

Response:

BYTE_ARRAY(1) [BYTE ARRAY]
[1 0 0 0 0 0 0 0]

If we operate on a more complex type, like a DATE the output is less readable. A DATE in bSQL is stored as a UINT16 and two UINT8's, hence length 4 byte array.

SELECT BYTE_ARRAY(2021-05-12);

Response:

BYTE_ARRAY(DATE(2021-05-12)) [BYTE ARRAY]
[229 7 5 12]