19 NLS and Globalization Support

Embed Size (px)

Citation preview

  • 8/6/2019 19 NLS and Globalization Support

    1/42

    NLS and Globalization

    Support

    NLS and Globalization

    Support

  • 8/6/2019 19 NLS and Globalization Support

    2/42

  • 8/6/2019 19 NLS and Globalization Support

    3/42

    Copyright 2002 Solutions IT services. All rights reserved

    Features in Globalization SupportFeatures in Globalization Support

    Language support

    Character set support

    Linguistic (Language based) sorting

    Territory/locale supportMessage support

    Date and time formats

    Calendar support

    Numeric formats

    Monetary formats

  • 8/6/2019 19 NLS and Globalization Support

    4/42

  • 8/6/2019 19 NLS and Globalization Support

    5/42

    Copyright 2002 Solutions IT services. All rights reserved

    Different Types

    of Encoding Formats

    Different Types

    of Encoding FormatsOracle 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)

  • 8/6/2019 19 NLS and Globalization Support

    6/42

  • 8/6/2019 19 NLS and Globalization Support

    7/42

  • 8/6/2019 19 NLS and Globalization Support

    8/42

    Copyright 2002 Solutions IT services. All rights reserved

    Database Character Sets and

    National Character Sets

    Database Character Sets and

    National Character SetsDatabase Character Sets National Character Sets

    Defined at database creation

    time

    Defined at database creation

    time

    May not be change without

    re-creating database

    May not be changed without

    re-creating database

    Store data columns of typeCHAR,VARCHAR2, CLOB, LONG

    Store data columns of typeNCHAR,NVARCHAR2,NCLOB

    Can store varying-widthcharacter sets Can store Unicode usingeither AL16UTF16 or UTF8

  • 8/6/2019 19 NLS and Globalization Support

    9/42

    Copyright 2002 Solutions IT services. All rights reserved

    Considerations for Choosing an

    OracleDatabase Character Set

    Considerations for Choosing an

    OracleDatabase Character SetWhat 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?

    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?

  • 8/6/2019 19 NLS and Globalization Support

    10/42

    Copyright 2002 Solutions IT services. All rights reserved

  • 8/6/2019 19 NLS and Globalization Support

    11/42

    Copyright 2002 Solutions IT services. All rights reserved

    Considerations for Choosing an

    Oracle National Character Set

    Considerations for Choosing an

    Oracle National Character SetTwo 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)

    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)

  • 8/6/2019 19 NLS and Globalization Support

    12/42

    12

    Choosing a Unicode Solution

    UnicodeDatabase

    Choosing a Unicode Solution

    UnicodeDatabaseWhen to Use a Unicode Database?

    Databases for web

    Easy code migration for Java or PL/SQL

    Easy data migration from ASCII based dataEvenly distributed multilingual data

    InterMedia Text Search usage

  • 8/6/2019 19 NLS and Globalization Support

    13/42

    13

    Choosing a Unicode Solution

    UnicodeDatatype

    Choosing a Unicode Solution

    UnicodeDatatypeWhen to use a Unicode datatype?

    Adding multilingual support incrementally (withoutmigrating)

    Packaged applications to work with any character set onthe client database

    Performance

    Single byte database character set with a fixed widthnational character set

    Better support for UTF-16 with windows clients

    Note: Preferably use NCHAR datatype

  • 8/6/2019 19 NLS and Globalization Support

    14/42

    Copyright 2002 Solutions IT services. All rights reserved

    Specifying Language-Dependent

    Behavior

    Specifying Language-Dependent

    Behavior

    Initialization parameters

    Environment variables

    ALTER SESSION

    COMMAND

    High

    Low

    P

    re

    c

    e

    d

    e

    n

    c

    e

  • 8/6/2019 19 NLS and Globalization Support

    15/42

    Copyright 2002 Solutions IT services. All rights reserved

    Specifying Language-Dependent

    Behavior for the Server

    Specifying Language-Dependent

    Behavior for the ServerNLS_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 ISOand local currency symbols

    Default calendar

  • 8/6/2019 19 NLS and Globalization Support

    16/42

    Copyright 2002 Solutions IT services. All rights reserved

    Dependent Language and

    TerritoryDefault Values

    Dependent Language and

    TerritoryDefault Values

    AMERICA$

    AMERICADD-MON-RR

    ,.GREGORIAN

    NLS_TERRITORYNLS_CURRENCYNLS_ISO_CURRENCYNLS_DATE_FORMAT

    NLS_NUMERIC_CHARACTERSNLS_CALENDAR

    AMERICAN

    AMERICANBINARY

    NLS_LANGUAGE

    NLS_DATE_LANGUAGENLS_SORT

    DEFAULT VALUESPARAMETER

  • 8/6/2019 19 NLS and Globalization Support

    17/42

  • 8/6/2019 19 NLS and Globalization Support

    18/42

    Copyright 2002 Solutions IT services. All rights reserved

    Specifying Language-Dependent

    Behavior for the Session

    Specifying Language-Dependent

    Behavior for the SessionEnvironment variable:

    NLS_LANG = _.

    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

  • 8/6/2019 19 NLS and Globalization Support

    19/42

    Copyright 2002 Solutions IT services. All rights reserved

    Character Sets

    in Client-Server Architecture

    Character Sets

    in Client-Server ArchitectureCREATE DATABASE ...

    CHARACTER SET

    NATIONAL CHARACTER SET

    ...

    NLS_LANG=_.

    NLS_NCHAR=

  • 8/6/2019 19 NLS and Globalization Support

    20/42

  • 8/6/2019 19 NLS and Globalization Support

    21/42

    Copyright 2002 Solutions IT services. All rights reserved

    Specifying Language-Dependent

    Behavior for the Session

    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) ;

  • 8/6/2019 19 NLS and Globalization Support

    22/42

    Copyright 2002 Solutions IT services. All rights reserved

    Linguistic SortingLinguistic SortingOracle supports three types of sorting

    Binary sorting

    Sorted according to the binary values of the

    encoded charactersMonolingual sorting

    Sorts are done in two passes

    Based on the character's assigned major and minorvalues

    Multilingual sorting Based on the new ISO 14651 standards and,

    Unicode 3.0 Standard for multilingual collation

  • 8/6/2019 19 NLS and Globalization Support

    23/42

    Copyright 2002 Solutions IT services. All rights reserved

    NLS SortingNLS SortingNLS_SORT specifies which type of sort is to be

    done for character data

    Is governed by theNLS_LANG environment variable

    can be specified directly at the session level

    NLSSORT function

    Specifies the type of sort for character data within a

    query

  • 8/6/2019 19 NLS and Globalization Support

    24/42

  • 8/6/2019 19 NLS and Globalization Support

    25/42

  • 8/6/2019 19 NLS and Globalization Support

    26/42

    Copyright 2002 Solutions IT services. All rights reserved

    Using NLS Parameters

    in SQL Functions

    Using NLS Parameters

    in SQL FunctionsSELECT 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;

  • 8/6/2019 19 NLS and Globalization Support

    27/42

  • 8/6/2019 19 NLS and Globalization Support

    28/42

  • 8/6/2019 19 NLS and Globalization Support

    29/42

  • 8/6/2019 19 NLS and Globalization Support

    30/42

    Linguistic Indexing SupportLinguistic Indexing Support

    Language based indexing

    High performance with local sorting

    NLS_COMP parameter can be used for linguisticcomparisons

    CREATE INDEX list_word ONlist (NLSSORT(word, NLS_SORT = French));

  • 8/6/2019 19 NLS and Globalization Support

    31/42

    Copyright 2002 Solutions IT services. All rights reserved

    Import and LoadingData

    Using NLS********go to mod 2

    Import and LoadingData

    Using NLS********go to mod 2Data 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 byNLS_LANG.

    DIRECT: Data is converted directly into the database

    character set.

  • 8/6/2019 19 NLS and Globalization Support

    32/42

    Copyright 2002 Solutions IT services. All rights reserved

    Obtaining Information

    About Character Sets

    Obtaining Information

    About Character SetsNLS_DATABASE_PARAMETERS:

    PARAMETER(NLS_CHARACTERSET,NLS_NCHAR_CHARACTERSET)

    VALUE

  • 8/6/2019 19 NLS and Globalization Support

    33/42

    Copyright 2002 Solutions IT services. All rights reserved

    Obtaining Information

    About NLS Settings

    Obtaining Information

    About NLS SettingsNLS_INSTANCE_PARAMETERS:

    PARAMETER(initialization parameters that have

    been explicitly set)

    VALUENLS_SESSION_PARAMETERS:

    PARAMETER(session parameters)

    VALUE

  • 8/6/2019 19 NLS and Globalization Support

    34/42

  • 8/6/2019 19 NLS and Globalization Support

    35/42

    Copyright 2002 Solutions IT services. All rights reserved

    Obtaining Information About

    NLS and Globalization Support

    Obtaining Information About

    NLS and Globalization SupportDynamic 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

  • 8/6/2019 19 NLS and Globalization Support

    36/42

  • 8/6/2019 19 NLS and Globalization Support

    37/42

    Copyright 2002 Solutions IT services. All rights reserved

    Globalization Support

    Utilities

    Globalization Support

    UtilitiesCharacter 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 localedefinitions and creating new ones

  • 8/6/2019 19 NLS and Globalization Support

    38/42

    Copyright 2002 Solutions IT services. All rights reserved

    SummarySummary

    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 availableencoding 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

    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 availableencoding 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

  • 8/6/2019 19 NLS and Globalization Support

    39/42

  • 8/6/2019 19 NLS and Globalization Support

    40/42

    40

    Practice 19 Overview

    This practice covers the following topics:

    Checking the database and national character set

    Identifying valid NLS values

    Setting NLS parameters

  • 8/6/2019 19 NLS and Globalization Support

    41/42

    41

  • 8/6/2019 19 NLS and Globalization Support

    42/42

    42