PolarDB for PostgreSQL(Compatible with Oracle) 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 for PostgreSQL(Compatible with Oracle) database for a PolarDB for PostgreSQL(Compatible with Oracle) 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 for PostgreSQL(Compatible with Oracle) database for a PolarDB for PostgreSQL(Compatible with Oracle) 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

FunctionData type of the input parameterData type of the output
TO_SINGLE_BYTECHARCHAR
TO_SINGLE_BYTECHARACTER VARYINGCHARACTER VARYING
TO_SINGLE_BYTETEXTTEXT
TO_MULTI_BYTECHARCHAR
TO_MULTI_BYTECHARACTER VARYINGCHARACTER VARYING
TO_MULTI_BYTETEXTTEXT

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)