在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()函數,都可以實現字符類型的轉換。