What MySQL returns if we provide value larger than 255 as argument to MySQL CHAR() function?


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: 22-Jun-2020

55 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements