MySQL CHAR Function Return Value for Argument Over 255



MySQL converts the arguments of CHAR() function which is greater than 255 to multiple result bytes. For example, CHAR(260) is equivalent to CHAR(0,1,0,4). It can be more clear with the help of following statements −

mysql> Select HEX(CHAR(256)),HEX(CHAR(1,0));
+----------------+----------------+
| HEX(CHAR(256)) | HEX(CHAR(1,0)) |
+----------------+----------------+
| 0100           | 0100           |
+----------------+----------------+
1 row in set (0.00 sec)

The above result set shows that CHAR(256) is equivalent to CHAR(1,0).

Updated on: 2020-06-22T06:10:54+05:30

104 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements