在MySQL中,可以使用CAST()函数或CONVERT()函数来转换字符类型。
示例:
SELECT CAST('123' AS CHAR) AS char_value;
SELECT CAST('123' AS VARCHAR(10)) AS varchar_value;
SELECT CAST('123' AS TEXT) AS text_value;
示例:
SELECT CONVERT('123', CHAR) AS char_value;
SELECT CONVERT('123', VARCHAR(10)) AS varchar_value;
SELECT CONVERT('123', TEXT) AS text_value;
无论是使用CAST()函数还是CONVERT()函数,都可以实现字符类型的转换。