PolarDB-O is compatible with Oracle databases and provides TO_SINGLE_BYTE and TO_MULTI_BYTE functions. The TO_SINGLE_BYTE function returns a string where all the multibyte characters are converted to the corresponding single-byte characters. The TO_MULTI_BYTE function returns a string where all the single-byte characters are converted to the corresponding multibyte characters.

Usage notes

When you create a PolarDB-O database for a PolarDB-O cluster created on or after March 30, 2020, the TO_SINGLE_BYTE and TO_MULTI_BYTE plug-ins are automatically created.

When you create a PolarDB-O database for a PolarDB-O cluster created before March 30, 2020, the plug-ins are not automatically created. To use the plug-ins, you must execute the following statement to manually create the plug-ins after you create the database.

CREATE EXTENSION polar_to_single_byte;

For more information about the plug-ins, see TO_SINGLE_BYTE and TO_MULTI_BYTE.

Interfaces

Function Data type of the input parameter Data type of the output
TO_SINGLE_BYTE CHAR CHAR
TO_SINGLE_BYTE CHARACTER VARYING CHARACTER VARYING
TO_SINGLE_BYTE TEXT TEXT
TO_MULTI_BYTE CHAR CHAR
TO_MULTI_BYTE CHARACTER VARYING CHARACTER VARYING
TO_MULTI_BYTE TEXT TEXT

Usage method

-- to_single_byte
SELECT to_single_byte('123$test');
 to_single_byte 
----------------
 123$test
(1 row)

-- to_multi_byte
SELECT to_multi_byte('123$test');
  to_multi_byte   
------------------
 123$test
(1 row)