All Products
Search
Document Center

PolarDB:TRANSLATE ... USING

Last Updated:Oct 27, 2025

When you migrate applications from Oracle to PolarDB, code containing Oracle-specific TRANSLATE ... USING syntax may fail to execute. To simplify migrations, PolarDB is now compatible with this syntax, allowing existing code to run without modification.

Applicability

Your PolarDB for PostgreSQL (Compatible with Oracle) cluster must run minor engine version 2.0.14.18.37.0 or later.

Note

You can view the minor engine version in the console or run the SHOW polardb_version; statement. If your cluster does not meet the version requirement, upgrade the minor engine version.

How it works

TRANSLATE ... USING is intended only for Oracle syntax compatibility, not for providing equivalent functionality.

Dimension

Oracle

PolarDB (Key differences)

Main purpose

Performs character encoding conversion between the database character set CHAR_CS and the national character set NCHAR_CS.

Used only for syntax compatibility. Ensures that code containing this syntax can be parsed and executed successfully.

Conversion behavior

Performs a byte-level conversion.

No character set conversion occurs. The expression behaves like a CAST(expr AS VARCHAR) type cast and returns the input content unchanged.

USING CHAR_CS

Converts the expression to the database character set and returns VARCHAR2.

Returns the VARCHAR type. The content is identical to the input string.

USING NCHAR_CS

Converts the expression to the national character set and returns NVARCHAR2.

Returns the VARCHAR type. The content is identical to the input string. There is no functional difference from USING CHAR_CS.

Examples

Verify syntax compatibility

Verify that the TRANSLATE USING expression does not alter the content of a string, even when it contains multi-byte characters (like Chinese).

Run the following SQL statement:

SELECT 
    TRANSLATE('Hello, PolarDB' USING CHAR_CS) AS result_char_cs,
    TRANSLATE('Hello, PolarDB' USING NCHAR_CS) AS result_nchar_cs;

Expected result

The two columns in the result are identical. This proves that the CHAR_CS and NCHAR_CS clauses have no functional difference in PolarDB.

 result_char_cs | result_nchar_cs 
----------------+-----------------
 Hello, PolarDB   | Hello, PolarDB

Perform an actual character set conversion

To perform an actual character set encoding conversion, such as from UTF8 to LATIN1, do not use TRANSLATE USING. Instead, use the standard CONVERT() function.