I'm reading the doc of MySQL. Where I found the UNHEX function is described as:
For a string argument str, UNHEX(str) interprets each pair of characters in the argument as a hexadecimal number and converts it to the byte represented by the number. The return value is a binary string.
mysql> SELECT UNHEX('4D7953514C');
-> 'MySQL'
mysql> SELECT X'4D7953514C';
-> 'MySQL'
mysql> SELECT UNHEX(HEX('string'));
-> 'string'
mysql> SELECT HEX(UNHEX('1267'));
-> '1267'
What is a "binary string"? Is it a general term or a term specifically used in MySQL?
I thought that if it is a "binary" data, then it shouldn't be called as a "string"(array of chars). So I'm wondering what is "binary string"?? does it means "array of bytes"?
I assume that eventually every datatype will be converted into binary data. And so does the "String Types" in MySQL. What makes the difference from a "string" and a "binary string" is that the "character string" has some information about what encoding schema and collation to be used when MySQL covert it from binary to a character string.
So what I don't quite understand is that why UNHEX('4D7953514C') returns a "character string" 'MySQL' but not a "binary string" represented by a sequence of 0s and 1s(0100 1101 0111 1001 0101 0011 0101 0001 0100 1100).