Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 42

NLS and Globalization Support

Objectives
After completing this lesson, you should be able to: Choose database character set and national character set of a database Outline the pros and cons of different available encoding formats Configure the language-dependent behavior using initialization parameters, environment variables, and the ALTER SESSION command Use the different types of National Language Support (NLS) parameters Explain the influence on language-dependent application behavior Obtain the NLS and Globalization information of the database
Copyright 2002 Solutions IT services. All rights reserved

Features in Globalization Support


Language support Character set support Linguistic (Language based) sorting Territory/locale support Message support Date and time formats Calendar support Numeric formats Monetary formats

Copyright 2002 Solutions IT services. All rights reserved

Different Types of Encoding Formats


Oracle supports various classes of character Encoding Format: Single-byte character sets
7-bit per Character 8-bit per Character

Varying-width multibyte character sets Fixed-width multibyte character sets Unicode (AL32UFT8, AL16UTF16, UTF8)

Copyright 2002 Solutions IT services. All rights reserved

Database Character Sets and National Character Sets


Database Character Sets
Defined at database creation time May not be change without re-creating database Store data columns of type CHAR, VARCHAR2, CLOB, LONG Can store varying-width character sets

National Character Sets


Defined at database creation time May not be changed without re-creating database Store data columns of type NCHAR, NVARCHAR2, NCLOB Can store Unicode using either AL16UTF16 or UTF8

Copyright 2002 Solutions IT services. All rights reserved

Considerations for Choosing an Oracle Database Character Set


What language does the database need to support? What are interoperability concerns with system resources and applications? What are the performance implications? What are the restrictions?

Copyright 2002 Solutions IT services. All rights reserved

Copyright 2002 Solutions IT services. All rights reserved

Considerations for Choosing an Oracle National Character Set


Two choices
AL16UTF16 (default) [ fixed width 2 bytes ] UTF8 [ variable width 1-3 bytes ]

Is space an issue? (Use AL16UTF16 for American and Europian and use UTF8 for Asian) Is performance an issue? (Use fixed width Character set AL16UTF16)

Copyright 2002 Solutions IT services. All rights reserved

Choosing a Unicode Solution Unicode Database


When to Use a Unicode Database? Databases for web Easy code migration for Java or PL/SQL Easy data migration from ASCII based data Evenly distributed multilingual data InterMedia Text Search usage

12

Choosing a Unicode Solution Unicode Datatype


When to use a Unicode datatype? Adding multilingual support incrementally (without migrating) Packaged applications to work with any character set on the client database Performance Single byte database character set with a fixed width national character set Better support for UTF-16 with windows clients Note: Preferably use NCHAR datatype

13

Specifying Language-Dependent Behavior


High
ALTER SESSION COMMAND P r e c e d e n c e

Environment variables Initialization parameters Low


Copyright 2002 Solutions IT services. All rights reserved

Specifying Language-Dependent Behavior for the Server


NLS_LANGUAGE specifies: The language for messages coming from database Names of Day and month Symbols for A.D, B.C, A.M, P.M. The default sorting mechanism NLS_TERRITORY specifies: Numbering of Days and weeks Default date format, decimal character, group separator character, and the default ISO and local currency symbols Default calendar

Copyright 2002 Solutions IT services. All rights reserved

Dependent Language and Territory Default Values


PARAMETER NLS_LANGUAGE
NLS_DATE_LANGUAGE NLS_SORT

DEFAULT VALUES AMERICAN


AMERICAN BINARY

NLS_TERRITORY
NLS_CURRENCY NLS_ISO_CURRENCY NLS_DATE_FORMAT NLS_NUMERIC_CHARACTERS NLS_CALENDAR

AMERICA
$ AMERICA DD-MON-RR ,. GREGORIAN

Copyright 2002 Solutions IT services. All rights reserved

Specifying Language-Dependent Behavior for the Session


Environment variable: NLS_LANG = <language>_<territory>.<charset> e.g.: NLS_LANG = French_France.UTF8 Additional environment variables:
NLS_DATE_FORMAT NLS_DATE_LANGUAGE NLS_SORT NLS_NUMERIC_CHARACTERS NLS_CURRENCY NLS_ISO_CURRENCY NLS_CALENDAR NLS_TIME_FORMAT NLS_TIMESTAMP_FORMAT
Copyright 2002 Solutions IT services. All rights reserved

Character Sets in Client-Server Architecture


CREATE DATABASE ... CHARACTER SET <charset> NATIONAL CHARACTER SET <ncharset> ...

NLS_LANG=<language>_<territory>.<charset> NLS_NCHAR=<ncharset>

Copyright 2002 Solutions IT services. All rights reserved

Specifying Language-Dependent Behavior for the Session


ALTER SESSION SET NLS_DATE_FORMAT=DD.MM.YYYY; DBMS_SESSION.SET_NLS(NLS_DATE_FORMAT, DD.MM.YYYY) ;

Copyright 2002 Solutions IT services. All rights reserved

Linguistic Sorting
Oracle supports three types of sorting Binary sorting
Sorted according to the binary values of the encoded characters

Monolingual sorting
Sorts are done in two passes Based on the character's assigned major and minor values

Multilingual sorting
Based on the new ISO 14651 standards and, Unicode 3.0 Standard for multilingual collation

Copyright 2002 Solutions IT services. All rights reserved

NLS Sorting
NLS_SORT specifies which type of sort is to be done for character data
Is governed by the NLS_LANG environment variable can be specified directly at the session level

NLSSORT function
Specifies the type of sort for character data within a query

Copyright 2002 Solutions IT services. All rights reserved

Using NLS Parameters in SQL Functions


SELECT TO_CHAR(hire_date,DD.Month.YYYY, NLS_DATE_LANGUAGE=GERMAN) FROM scott.emp;

SELECT first_name, TO_CHAR(salary,9G999D99, NLS_NUMERIC_CHARACTERS=,.) FROM scott.emp;

Copyright 2002 Solutions IT services. All rights reserved

Linguistic Indexing Support


Language based indexing High performance with local sorting
CREATE INDEX list_word ON list (NLSSORT(word, NLS_SORT = French));

NLS_COMP parameter can be used for linguistic comparisons

Import and Loading Data Using NLS********go to mod 2


Data will be converted from export file character set to the database character set during the import. LOADER:
Conventional: Data is converted into the session character set specified by NLS_LANG. DIRECT: Data is converted directly into the database character set.

Copyright 2002 Solutions IT services. All rights reserved

Obtaining Information About Character Sets


NLS_DATABASE_PARAMETERS: PARAMETER (NLS_CHARACTERSET, NLS_NCHAR_CHARACTERSET) VALUE

Copyright 2002 Solutions IT services. All rights reserved

Obtaining Information About NLS Settings


NLS_INSTANCE_PARAMETERS: PARAMETER (initialization parameters that have been explicitly set) VALUE NLS_SESSION_PARAMETERS: PARAMETER (session parameters) VALUE

Copyright 2002 Solutions IT services. All rights reserved

Obtaining Information About NLS and Globalization Support


Dynamic Performance Views : V$NLS_VALID_VALUES: PARAMETER (LANGUAGE, SORT, TERRITORY, CHARACTERSET) VALUE : All acceptable valid values for the parameter V$NLS_PARAMETERS: PARAMETER (NLS session parameters, NLS_CHARACTERSET) VALUE : current values for the parameter

Copyright 2002 Solutions IT services. All rights reserved

Globalization Support Utilities


Character Set Scanner Scans the database to determine whether the character set can successfully be changed Reports are provided having detailed possible problems and their rectifications Oracle Locale Builder Easy to operate graphical interface For viewing and modifying existing locale definitions and creating new ones

Copyright 2002 Solutions IT services. All rights reserved

Summary
In this lesson, you should have learned to: Choose a database character set and a national character set for the database Outline the pros and cons of different available encoding formats Use the various types of National Language Support parameters for the server, or the session Outline the usage of Globalization Support Utilities Obtain the NLS and Globalization information of the database

Copyright 2002 Solutions IT services. All rights reserved

Practice 19 Overview
This practice covers the following topics: Checking the database and national character set Identifying valid NLS values Setting NLS parameters

40

41

42

You might also like