12.07.2015 Views

Oracle SQL Developer

Oracle SQL Developer

Oracle SQL Developer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>SQL</strong> and PL/<strong>SQL</strong> Programming with Unicode11.3.2.1 The NCHAR Data TypeWhen you define a table column or a PL/<strong>SQL</strong> variable as the NCHAR data type, thelength is always specified as the number of characters. For example, the followingstatement creates a column with a maximum length of 30 characters:CREATE TABLE table1 (column1 NCHAR(30));The maximum number of bytes for the column is determined as follows:maximum number of bytes =(maximum number of characters) x (maximum number of bytes for each character)For example, if the national character set is UTF8, then the maximum byte length is 30characters times 3 bytes for each character, or 90 bytes.The national character set, which is used for all NCHAR data types, is defined when thedatabase is created. The national character set can be either UTF8 or AL16UTF16. Thedefault is AL16UTF16.The maximum column size allowed is 2000 characters when the national character setis UTF8 and 1000 when it is AL16UTF16. The actual data is subject to the maximumbyte limit of 2000. The two size constraints must be satisfied at the same time. InPL/<strong>SQL</strong>, the maximum length of NCHAR data is 32767 bytes. You can define an NCHARvariable of up to 32767 characters, but the actual data cannot exceed 32767 bytes. Ifyou insert a value that is shorter than the column length, then <strong>Oracle</strong> pads the valuewith blanks to whichever length is smaller: maximum character length or maximumbyte length.Note: UTF8 may affect performance because it is a variable-widthcharacter set. Excessive blank padding of NCHAR fields decreasesperformance. Consider using the NVARCHAR data type or changingto the AL16UTF16 character set for the NCHAR data type.11.3.2.2 The NVARCHAR2 Data TypeThe NVARCHAR2 data type specifies a variable length character string that uses thenational character set. When you create a table with an NVARCHAR2 column, youspecify the maximum number of characters for the column. Lengths for NVARCHAR2are always in units of characters, just as for NCHAR. <strong>Oracle</strong> subsequently stores eachvalue in the column exactly as you specify it, if the value does not exceed the column'smaximum length. <strong>Oracle</strong> does not pad the string value to the maximum length.The maximum column size allowed is 4000 characters when the national character setis UTF8 and 2000 when it is AL16UTF16. The maximum length of an NVARCHAR2column in bytes is 4000. Both the byte limit and the character limit must be met, so themaximum number of characters that is actually allowed in an NVARCHAR2 column isthe number of characters that can be written in 4000 bytes.In PL/<strong>SQL</strong>, the maximum length for an NVARCHAR2 variable is 32767 bytes. You candefine NVARCHAR2 variables up to 32767 characters, but the actual data cannot exceed32767 bytes.The following statement creates a table with one NVARCHAR2 column whosemaximum length in characters is 2000 and maximum length in bytes is 4000.CREATE TABLE table2 (column2 NVARCHAR2(2000));11-20 <strong>SQL</strong> <strong>Developer</strong> Online Help

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!