Name

CONVERT and TRANSLATE

The CONVERT function alters the representation of a character string within its character set and collation. For example, CONVERT might be used to alter the number of bits per character.

TRANSLATE alters the character set of a string value from one base character set to another. Thus, TRANSLATE might be used to translate a value from the English character set to a Kanji (Japanese) or Cyrillic (Russian) character set. The translation must already exist, either by default or by virtue of having been created using the CREATE TRANSLATION command.

ANSI SQL Standard Syntax

CONVERT(char_value USING conversion_char_name)

TRANSLATE(char_value USING translation_name)

CONVERT converts char_value to the character set with the name supplied in conversion_char_name. TRANSLATE converts char_value to the character set provided in translation_name.

MySQL

MySQL supports the ANSI SQL syntax for CONVERT but does not support TRANSLATE.

Oracle

Oracle supports CONVERT and TRANSLATE with the same meaning as ANSI SQL. The Oracle syntax follows:

CONVERT(char_value, target_char_set, source_char_set)

TRANSLATE(char_value USING {CHAR_CS | NCHAR_CS})

Under Oracle’s implementation, the CONVERT function returns the text of char_value in the target character set. char_value is the string to convert, target_char_set is the name of the character set into which the string is to be converted, and source_char_set is the name of the character set in which char_value was originally stored.

Oracle’s TRANSLATE ...

Get SQL in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.