to_binary()

Scalar. Converts a given value to a binary value.

Syntax

to_binary ( value )

Parameter

value

The value you wish to cast to is either string or binary type.

Usage

Converts a given string to a binary value. The function takes a string as its argument, and the function returns a binary value. Note that the function can also take a binary value as its argument, but it will return the same binary value.

Examples

to_binary('0123456789abcdef') returns a binary value equivalent to 0x30313233343536373839616263646566

to_binary('Hello there!') returns a binary value equivalent to 0x48656c6c6f20746865726521

to_string( to_binary('Good morning.')) returns the string 'Good morning.' after casting it to binary type and then back to string type.