Lesson 6 | Character Set Conversion |
Objective | Understand how Oracle converts between character sets. |
CONVERT
function. The syntax for the function is
CONVERT(char, dest_char_set, [src_char_set])
TRANSLATE USING
function to translate values into either the database character set or the national character set for the database. The syntax for the function is
TRANSLATE text USING CHAR_CS/NCHAR_CS
CHAR_CS
indicates that you want to convert the string to the database character set, with an output type of VARCHAR2
; and NCHAR_CS
indicates that you want to convert the string to the national character set, with an output type of NVARCHAR2
.TO_CHAR, TO_DATE
, and TO_NUMBER
functions can have an optional parameter specified to indicate that the source is in a particular national character set.NLS_UPPER, NLS_LOWER
, and NLS_INITCAP
functions take into account the fact that certain national character sets have different rules for uppercase, lowercase,
and initial capitalization. These functions take these differences into account when you specify an NLS_SORT
parameter.NLS_SORT
is used when you want to compare values based on their order in the specified national language set. Normally, comparisons in a WHERE
clause are made with binary values.
If your national language was German and you wanted to compare two values based on their German sort order, you would use the syntax WHERE NLS_SORT(value1) > NLS_SORT(value2). NLS_SORT
would operate: