the NVARCHAR2 and NCHAR datatypes represent character data using the national character set rather than the database character set. In addition, they are always declared using character semantics (no CHAR qualifier applies). Other than those two differences, NVARCHAR2 and NCHAR are just like their counterparts, VARCHAR2 and CHAR. Use NVARCHAR2 for variable-length strings in the national character set, and use NCHAR for fixed-length strings in the national character set.
Following are some exampledeclarations:
line_of_text NVARCHAR2(2000); -- 2000 characters, variable-lengthfeature_name NCHAR(100); -- 100 characters, fixed-lengthPrior to Oracle9i, the national character set could be any one of a large number of single- and multibyte character sets. Beginning with Oracle9i, the national character set used by NCHAR and NVARCHAR2 variables must be either UTF-8 (multibyte, variable-width) or UTF-16 (multibyte, fixed-width).
|
The NVARCHAR2 and NCHAR types have been improved in Oracle9i, and you may now freely mix them in expressions involving VARCHAR2 and CHAR. Prior to Oracle9i, for example, if you attempted to compare a VARCHAR2 value with an NVARCHAR2 value, PL/SQL would return a PLS-00561: character set mismatch error. In Oracle9i, such expressions are possible. Of course, you pay a penalty in terms of efficiency, because PL/SQL must implicitly convert the values to a common character set.