Unicode and SQL*Plus (UNIX)


To display characters properly SQL*Plus (character mode version) needs to know the character set being used to display its output on the client. A setting called NLS_LANG controls this. NLS_LANG has three components -- language, territory, and character set. Any one, two, or three of these components can be specified in an NLS_LANG settings. Here are some examples.

NLS_LANG Setting Components That Are Set
Character Set
Language, Territory
Language, Character Set
Language, Territory, Character Set

It is important to note the following.

  • NLS_LANG identifies the character set used by the client, not the server
  • NLS_LANG cannot be changed via an ALTER SESSION command (though the language and territory components can be overridden with ALTER SESSION SET NLS_LANGUAGE or ALTER SESSION SET NLS_TERRITORY)

To determine a session's NLS_LANG setting SQL*Plus either uses the value stored in the operating system's NLS_LANG environment variable or, if no such variable exists, it defaults to US7ASCII.

On UNIX/Linux systems when the session's locale codeset is set to UTF-8 then NLS_LANG's character set component should be set to AL32UTF8, which is Oracle's UTF-8 character set. See Unicode on UNIX for more information about the UNIX "locale" feature and Oracle.

Spool Files

SQL*Plus spool files are created using the encoding associated with the NLS_LANG character set.

Linking to SQL Snippets ™

To link to this page in Oracle Technology Network Forums or OraFAQ Forums cut and paste this code.

  • [url=http://www.sqlsnippets.com/en/topic-13432.html]SQL Snippets: Unicode - Unicode and SQL*Plus (UNIX)[/url]

To link to this page in HTML documents or Blogger comments cut and paste this code.

  • <a href="http://www.sqlsnippets.com/en/topic-13432.html">SQL Snippets: Unicode - Unicode and SQL*Plus (UNIX)</a>

To link to this page in other web sites use the following values.

  • Link Text : SQL Snippets: Unicode - Unicode and SQL*Plus (UNIX)
  • URL (href): http://www.sqlsnippets.com/en/topic-13432.html