Syntax
CHAR(value1,... [USING charset_name])
Purpose
CHAR() converts arguments to integers and return a string that consists of the code characters of the integers. Any NULL argument is skipped.
If an argument is greater than 255, the argument is converted into multiple bytes. For example, CHAR(256) is equivalent to CHAR(1,0), and CHAR(256*256) is equivalent to CHAR(1,0,0).
By default, CHAR() returns a string that uses the binary character set. You can use a USING clause to specify the character set for the return value.
obclient> select CHARSET(char('')), CHARSET(char('' USING utf8mb4));
+-------------------+---------------------------------+
| CHARSET(char('')) | CHARSET(char('' USING utf8mb4)) |
+-------------------+---------------------------------+
| binary | utf8mb4 |
+-------------------+---------------------------------+
1 row in set
If the return value is invalid in the specified character set, a WARNING is prompted. In particular, if sql_mode is set to STRICT_ALL_TABLES or STRICT_TRANS_TABLES, and the return value is invalid in the specified character set, NULL is returned.
For information about sql_mode, see sql_mode.
obclient> SET SESSION sql_mode='STRICT_ALL_TABLES';
obclient> SELECT CHAR(399 USING utf8);
+----------------------+
| CHAR(399 USING utf8) |
+----------------------+
| NULL |
+----------------------+
1 row in set, 1 warning
Examples
obclient> SELECT CHAR(79,99,101,97,110,66,97.4,115,'101');
+------------------------------------------+
| CHAR(79,99,101,97,110,66,97.4,115,'101') |
+------------------------------------------+
| OceanBase |
+------------------------------------------+
1 row in set