background image
<< Developing Globalized Applications | Using Unicode String Literals >>
<< Developing Globalized Applications | Using Unicode String Literals >>

Using SQL Character Data Types

Developing Globalized Applications
6-28 Oracle Database 2 Day Developer's Guide
types regardless of how the database character set has been defined. The
NCHAR
data type is an exclusively Unicode data type.
Using SQL Character Data Types
There are two SQL
NCHAR
data types:
NCHAR
and
NVARCHAR2
.
In SQL Developer, you can specify these data types in the dialog box for creating or
editing a table, by selecting the appropriate value for Type for each column. You can
also use the SQL Worksheet to enter a
CREATE TABLE
statement and specify each
column name and data type.
Using the NCHAR Data Type
When you define a table column or a PL/SQL variable as the
NCHAR
data type, the
length is specified as the number of characters. For example, the following statement
creates a column with a maximum length of 30 characters:
CREATE TABLE table1 (column1 NCHAR(30));
The maximum number of bytes in a column is the product of the maximum number of
characters and the maximum number of bytes for each character.
For example, if the national character set is UTF8, then the maximum byte length is 30
characters times 3 bytes for each character, or 90 bytes.
The national character set, which is used for all
NCHAR
data types, is defined when the
database is created. The national character set can be either UTF8 or AL16UTF16. The
default is AL16UTF16.
The maximum column size allowed is 2000 characters when the national character set
is UTF8 and 1000 when it is AL16UTF16. The actual data is subject to the maximum
byte limit of 2000. The two size constraints must be satisfied at the same time. In
PL/SQL, the maximum length of the
NCHAR
data is 32,767 bytes. You can define an
NCHAR
variable of up to 32,767 characters, but the actual data cannot exceed 32,767
bytes. If you insert a value that is shorter than the column length, then Oracle pads the
value with blanks to whichever length is smaller: maximum character length or
maximum byte length.
See Also:
Using SQL Character Data Types
on page 6-28
Using Unicode String Literals
on page 6-29
NCHAR Literal Replacement
on page 6-30
Oracle Database Globalization Support Guide for a complete
discussion of programming with Unicode
See Also:
Overview of Unicode
on page 6-27
Using Unicode String Literals
on page 6-29
NCHAR Literal Replacement
on page 6-30
Oracle Database Globalization Support Guide for a complete
discussion of programming with Unicode