Solution to the Failure of Converting the Field Type
Scenario
The varchar field is read using the char data type, and cannot be converted through the char() function.
Fault Analysis
The char() function cannot be used to convert data types.
Solution
The CAST() function and CONVERT() function of RDS for MySQL can be used to obtain values of one type and generate values of another type. The syntax is as follows:
CAST(value as type); CONVERT(value, type);
That is, CAST(xxx AS type) and CONVERT(xxx, type).
The data types that can be converted are limited. The supported data types are as follows:
- BINARY: the same as adding a binary prefix to a data string
- CHAR(): characters. You can specify the length of the characters.
- DATE: calendar date
- Time: time of day
- DATETIME: date and time
- DECIMAL: floating point number
- SIGNED: integer
- UNSIGNED: unsigned integer
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot