Binary
Description
The BINARY()
function is used to convert string-type data into a binary form byte stream. This function accepts a string parameter and returns a result of binary data type.
Syntax
Parameters
str
: The string type data that needs to be converted.
Return Result
- Returns a byte stream of binary data type.
Usage Example
-
Convert the string "hello" to binary form:
-
Convert a string containing special characters "élle!" to binary form:
Notes
- When the input string contains non-ASCII characters, the
BINARY()
function will perform an encoding conversion to correctly represent it in binary form. - When handling binary data, pay attention to the character set and collation settings to ensure the correctness and consistency of the data.
By using the BINARY()
function, you can easily store and manipulate binary data in the database, such as images, audio, and video files.