title | summary | aliases | ||
---|---|---|---|---|
Cast Functions and Operators |
Learn about the cast functions and operators. |
|
Cast functions and operators enable conversion of values from one data type to another. TiDB supports all of the cast functions and operators available in MySQL 5.7.
Name | Description |
---|---|
BINARY |
Cast a string to a binary string |
CAST() |
Cast a value as a certain type |
CONVERT() |
Cast a value as a certain type |
Note:
TiDB and MySQL display inconsistent results for
SELECT CAST(MeN AS CHAR)
(or its equivalent formSELECT CONVERT(MeM, CHAR)
), whereMeN
represents a double-precision floating-point number in scientific notation. MySQL displays the complete numeric value when-15 <= N <= 14
and the scientific notation whenN < -15
orN > 14
. However, TiDB always displays the complete numeric value. For example, MySQL displays the result ofSELECT CAST(3.1415e15 AS CHAR)
as3.1415e15
, while TiDB displays the result as3141500000000000
.