SESSION CHARSET - Basic Teradata Query - 16.20

Basic Teradata Query Reference

prodname
Basic Teradata Query
vrm_release
16.20
category
Programming Reference
featnum
B035-2414-108K

Purpose

This control enables users to specify the name of the character set for existing and future database sessions.

Syntax



where the following is true:

charstring
The name of the character set. Using the name, instead of the numeric code, is recommended.

The name cannot exceed 30 characters.

code
The numeric code for the character set.

Code range: 0 to 255

Usage Notes

You can choose the character set either by name or by numeric code. If selecting by name, the value should exist in the DBC.CharTranslations View CharSetName column. If selecting by code, the value should exist in the DBC.CharTranslations View CharSetId column. The validity of the specified character set's name or code is determined by Teradata Database when a subsequent SQL request is submitted.

The Teradata Database collation default on mainframe-attached systems is EBCDIC; the default for workstation-attached systems is ASCII.

For more information about these System Table views, refer to International Character Set Support (B035-1125).

The -c, -e, and -m command line options can also be used to initially set the session character set and I/O encoding for workstation-attached systems before any commands and, or statements are processed. For an interactive Unicode session, it is recommended that the -m option be used along with the -c option. This enables BTEQ to accept and display locale-specific characters, affecting stdio, RUN files, and MESSAGEOUT files. The SESSION CHARSET setting remains UTF8 or UTF16 which is used for all import, export, and SQL (internal) stored procedure files, as well as for communications to and from the database.

Examples for using the command line options:

Command Line Options Description
bteq Interactive mode where charset and I/O encoding default to ASCII.
bteq -c ASCII < script Batch mode using an ASCII script where charset and I/O encoding are ASCII.
bteq -c KANJISJIS_0S Interactive mode where charset and I/O encoding are KanjiShift-JIS.
bteq -c UTF8 < script Batch mode using a UTF-8 script where charset and I/O encoding are UTF8.
bteq -c UTF16 < script Batch mode using a UTF-16 script where charset and I/O encoding are UTF16.
bteq -e UTF8 -c UTF16 < script Batch mode using UTF-8 script where charset is UTF16 and I/O encoding is UTF8.
bteq -e 62 -c 63 < script Batch mode using a UTF-16 script where charset is UTF8 and I/O encoding is UTF16.
bteq -c UTF16 -m Interactive mode where charset is UTF16 and I/O encoding is based on locale.
bteq -c UTF8 -m Interactive mode where charset is UTF8 and I/O encoding is based on locale.

For mainframe-attached systems, command line options are not available. If the “charset_id” within the HSHSPB is not defined, BTEQ defaults the session character set and I/O encoding to EBCDIC.

For further information on command line options, see Command Line Options.

For workstation-attached systems, if these command line options and the “charset_id” value within the clispb.dat file are not used, BTEQ sets session character set and I/O encoding settings to ASCII.

For BTEQWIN, the SESSION CHARSET command has limited use. BTEQWIN supports only the session character sets ASCII, UTF8, UTF16, and KANJISJIS_0S. BTEQWIN does not support other charsets because the Unicode charsets can display the characters of most modern languages.

For mainframe-attached systems, a “code” should not be used for character sets. Though mainframe CLI might accept code for certain character sets, its support is deprecated, and does not work for Unicode charsets. Names should be used instead, both for HSHSPB entry and for SET SESSION CHARSET command.
The HELP SESSION command can be used to display the current collation and character set of a Teradata Database session. The actual columns returned for the response might vary depending on the Teradata Database release being used. For a more readable format, use FOLDLINE and SIDETITLES commands before specifying the command.
There are restrictions whenever a UTF-16 session is involved for workstation-attached systems as defined below:
If... Then...
Both the existing session character set and the I/O encoding are UTF16 or the -m option is used. The use of the SESSION CHARSET command is prohibited.
The existing session character set is UTF16 and the I/O encoding is UTF8. The new session character set is limited to UTF8.
The existing session character set is UTF8 and the I/O encoding is UTF16. The new session character set is limited to UTF16.
Both the existing session character set and the I/O encoding are UTF8. The new session character set cannot be UTF16.
The existing session character set is non-Unicode. The new session character set cannot be UTF16.
Avoid switching character sets if it is important to generate all non-Latin characters properly through stdout. Using the SESSION CHARSET command to switch character sets could cause a mixture of incompatible character repertoires depending upon the results from the database.

BTEQ does not enable switching to a non-ASCII charset when an export file is open or standard output is being written to a file opened by way of the MESSAGEOUT command. See MESSAGEOUT.

Example 1 – SESSION CHARSET

To change the character set to German during a session, type:

.SET SESSION CHARSET 'GermanASCII'

Example 2 – SESSION CHARSET

To return to the default character set, type:

.SET SESSION CHARSET
   

Example 3 – SESSION CHARSET

To see the character set established for your session, type:

.foldline on all
.sidetitles on
help session;

BTEQ Response

*** Help information returned. One row.
*** Total elapsed time was 1 second.
               User Name DBC
            Account Name DBC
              Logon Date 05/11/14
              Logon Time 10:21:40
        Current DataBase DBC
               Collation ASCII
           Character Set ASCII
   Transaction Semantics Teradata
        Current DateForm IntegerDate
       Session Time Zone  00:00
  Default Character Type LATIN
            Export Latin 1
          Export Unicode 1
   Export Unicode Adjust 0
        Export KanjiSJIS 1
          Export Graphic 0
     Default Date Format YY/MM/DD
         Radix Separator .
         Group Separator ,
           Grouping Rule 3
Currency Radix Separator .
Currency Group Separator ,
  Currency Grouping Rule 3
           Currency Name US Dollars
                Currency $
             ISOCurrency USD
      Dual Currency Name US Dollars
           Dual Currency $
        Dual ISOCurrency USD
  Default ByteInt format -(3)9
  Default Integer format -(10)9
 Default SmallInt format -(5)9
  Default Numeric format --(I).9(F)
     Default Real format -9.99999999999999E-999
     Default Time format HH:MI:SS.S(F)Z
Default Timestamp format YYYY-MM-DDBHH:MI:SS.S(F)Z
            Current Role
           Logon Account DBC
                 Profile
                    LDAP N
          Audit Trail Id DBC
 Current Isolation Level SR