CONVERT

2023-12-25 08:49:42  Updated

Purpose

CONVERT() converts a string from one character set to another.

Syntax

CONVERT(char, dest_char_set[, source_char_set])

Parameters

Parameter Description
char The string to be converted. It can be of any data type, such as CHAR, VARCHAR2, NCHAR, NVARCHAR2, and CLOB.
dest_char_set The name of the character set to which the string is converted.
source_char_set The name of character set that is used to store the string in the database. If you do not specify this parameter, its default value is the database character set.

Return type

  • If char is of the CHAR or VARCHAR2 data type, the return type is VARCHAR2.

  • If char is of the NCHAR or NVARCHAR2 data type, the return type is NVARCHAR2.

  • If char is of the CLOB data type, the return type is CLOB.

Examples

The following example converts the string Ä Ê Í a B c d to a string of the ZHS16GBK character set.

obclient> SELECT CONVERT('Ä Ê Í a b c d', 'ZHS16GBK') FROM DUAL;
+----------------------------------+
| CONVERT('ÄÊÍABCD','ZHS16GBK')    |
+----------------------------------+
| ? ? ? a b c d                    |
+----------------------------------+
1 row in set

Contact Us