Purpose
This function is used to convert character data into a VARCHAR type string.
Syntax statement
TO_CHAR(character)
Parameters
character: the character data to be converted.
Return type
- Returns data of the
VARCHARtype. - If the
charactervalue isNULL, returnNULL.
Examples
SELECT TO_CHAR('Hello, World!'), TO_CHAR(NULL);
The return result is as follows:
+--------------------------+---------------+
| TO_CHAR('Hello, World!') | TO_CHAR(NULL) |
+--------------------------+---------------+
| Hello, World! | NULL |
+--------------------------+---------------+
1 row in set