Syntax
CHAR(value1,... [USING charset_name])
Purpose
Converts each parameter to an integer and returns a string composed of characters whose code values are these integers, skipping NULL values.
Additionally, if a parameter exceeds 255, it will be converted into multiple result bytes. For example, CHAR(256) is equivalent to CHAR(1,0), and CHAR(256*256) is equivalent to CHAR(1,0,0).
By default, the character set of the string returned by CHAR() is binary. You can specify the character set using the USING clause.
obclient> select CHARSET(char('')), CHARSET(char('' USING utf8mb4));
+-------------------+---------------------------------+
| CHARSET(char('')) | CHARSET(char('' USING utf8mb4)) |
+-------------------+---------------------------------+
| binary | utf8mb4 |
+-------------------+---------------------------------+
1 row in set
If the returned value is invalid in the specified character set, a WARNING is thrown. Specifically, if sql_mode is set to STRICT_ALL_TABLES or STRICT_TRANS_TABLES, and the returned value is invalid in the specified character set, NULL is returned.
For more 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
