12.07.2015 Views

Oracle SQL Developer

Oracle SQL Developer

Oracle SQL Developer

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SQL</strong> and PL/<strong>SQL</strong> Programming with UnicodeCharacter semantics is useful for defining the storage requirements for multibytestrings of varying widths. For example, in a Unicode database (AL32UTF8), supposethat you need to define a VARCHAR2 column that can store up to five Chinesecharacters together with five English characters. Using byte semantics, this columnrequires 15 bytes for the Chinese characters, which are three bytes long, and 5 bytes forthe English characters, which are one byte long, for a total of 20 bytes. Using charactersemantics, the column requires 10 characters.The expressions in the following list use byte semantics. Note the BYTE qualifier in theVARCHAR2 expression and the B suffix in the <strong>SQL</strong> function name.■VARCHAR2(20 BYTE)■ SUBSTRB(string, 1, 20)The expressions in the following list use character semantics. Note the CHAR qualifierin the VARCHAR2 expression.■VARCHAR2(20 CHAR)■ SUBSTR(string, 1, 20)This topic includes the following topic:■ NLS_LENGTH_SEMANTICS on page 11-1811.2.9.1 NLS_LENGTH_SEMANTICSThe NLS_LENGTH_SEMANTICS parameter specifies BYTE (default) or CHAR semantics.By default, the character data types CHAR and VARCHAR2 are specified in bytes, notcharacters. Hence, the specification CHAR(20) in a table definition allows 20 bytes forstoring character data.NLS_LENGTH_SEMANTICS enables you to create CHAR, VARCHAR2, and LONG columnsusing either byte or character length semantics. NCHAR, NVARCHAR2, CLOB, and NCLOBcolumns are always character-based. Existing columns are not affected.Example 11–15 shows an example of creating a table. When the database character setis WE8MSWIN1252, the last_name column of the table can hold up to 10 WesternEuropean characters, occupying a maximum of 10 bytes. When the database characterset is Unicode (AL32UTF8), last_name can still hold up to 10 Unicode charactersregardless of the language; however, it can occupy a maximum of 40 bytes.Example 11–15 Length Semantics and CREATE TABLECREATE TABLE temp_employees_table( employee_id NUMBER(4), last_name VARCHAR2(10 CHAR), job_id VARCHAR2(9),manager_id NUMBER(4), hire_date DATE, salary NUMBER(7,2),department_id NUMBER(2)) ;See Also:■<strong>Oracle</strong> Database Concepts for more information about lengthsemantics11.3 <strong>SQL</strong> and PL/<strong>SQL</strong> Programming with Unicode<strong>SQL</strong> is the fundamental language with which all programs and users access data in an<strong>Oracle</strong> database either directly or indirectly. PL/<strong>SQL</strong> is a procedural language thatcombines the data manipulating power of <strong>SQL</strong> with the data processing power of11-18 <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!