This topic describes the conversion functions that are supported by PolarDB-X.

PolarDB-X supports the following conversion functions.

Function Description Example
BINARY Converts a string to a binary string.

SELECT BINARY "RUNOOB";

The following result is returned:

-> RUNOOB

CAST(x AS type) Converts one data type to another.

Execute the following statement to convert the STRING data type to the DATE data type.

SELECT CAST("2017-08-29" AS DATE);

The following result is returned:

-> 2017-08-29

CONVERT(s USING cs) Converts the character set of the s string to the cs character set.
  • SELECT CHARSET('ABC')

    The following result is returned:

    ->utf-8

  • SELECT CHARSET(CONVERT('ABC' USING gbk))

    The following result is returned:

    ->gbk