Purpose
This function converts characters to the specified database character set or national character set.
Syntax
TRANSLATE(char USING{ CHAR_CS | NCHAR_CS })
Parameters
Parameter |
Description |
|---|---|
| char | The string to be converted. The data type can be CHAR, VARCHAR2, NCHAR, NVARCHAR2, or CLOB. |
| CHAR_CS | Specifies to convert to the database character set. |
| NCHAR_CS | Specifies to convert to the national character set. |
Return type
If
CHAR_CSis specified, the return type isVARCHAR2.If
NCHAR_CSis specified, the return type isNVARCHAR2.
Examples
Specify the string OceanBase and output the string in VARCHAR2 and NVARCHAR2 types, and output the string length in bytes.
obclient> SELECT LENGTHB(TRANSLATE('OceanBase' USING CHAR_CS)) "VARCHAR2",
LENGTHB(TRANSLATE('OceanBase' USING NCHAR_CS)) "NVARCHAR2"
FROM DUAL;
+----------+-----------+
| VARCHAR2 | NVARCHAR2 |
+----------+-----------+
| 9 | 18 |
+----------+-----------+
1 row in set
