Usage Notes - Advanced SQL Engine - Teradata Database

SQL Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
tpf1598412463935.ditamap
dita:ditavalPath
tpf1598412463935.ditaval
dita:id
B035-1143
lifecycle
previous
Product Category
Teradata Vantage™

Storage

Character data is allocated either in terms of characters or in terms of bytes, depending on the server character set used. The number of bytes of storage per character also varies depending on the server character set, as illustrated by the following table.

Server Character Set Server Form-of-Use Server Space Allocation Sharable Among Heterogeneous Clients?
LATIN Fixed 8-bit LATIN Character-based Yes
UNICODE Fixed16-bit UNICODE
GRAPHIC Fixed 16-bit UNICODE
KANJISJIS Mixed single and multibyte KANJISJIS Byte-based Yes

External Representation of CHARACTER

Whenever a client application communicates with Vantage, it indicates its character set (form-of-use for character data). The server returns all character data to the client application in that form.

Any conversion to or from the client system data types is done by Vantage.

For information on the number of bytes exported for the CHARACTER type, see Teradata SQL Character Strings and Client Physical Bytes.

Display Format

The default display format of CHARACTER(n) is X(n). For example, X(5), where data ‘HELLO’ displays as ‘HELLO’.

GRAPHIC Data

You can use GRAPHIC to represent multibyte character data.

GRAPHIC(n) is equivalent to CHARACTER(n) CHARACTER SET GRAPHIC. For best practice, define all GRAPHIC(n) data as CHARACTER(n) CHARACTER SET GRAPHIC.

Each multibyte character in a graphic string is stored assuming two bytes per logical character. Therefore, a graphic data string always represents an even multiple of bytes.

If you specify GRAPHIC without the length (n), the default is GRAPHIC(1).

The following rules apply to truncation and padding of GRAPHIC data.

IF a graphic string is … THEN …
shorter than the specified length of the column the remaining space is filled with the graphic pad character.
longer than the specified length of the column the extra characters are truncated.

External Representation of GRAPHIC

The following table lists the client representation for the IBM DB2 GRAPHIC type.

Determining the application definitions and client data types is the responsibility of the application programmer.

Client CPU Architecture Client Internal Data Format
IBM mainframe 2n bytes of n DB2 GRAPHIC characters.

GRAPHIC Data and Client Character Sets

GRAPHIC types accommodate the following client character sets:
  • KanjiEBCDIC double byte graphic data
  • KanjiShift-JIS for double byte Shift-JIS codes
  • KanjiEUC for fixed-length, double byte EUC characters
Use the following syntax for KanjiEBCDIC graphic string literals:
G '<graphic_characters>'

Under a KanjiEBCDIC character set, multibyte characters in a graphic string constant must be delimited with the Shift-Out/Shift-In characters; for example:

INSERT INTO TableEBCDIC (ColGRAPH)
 VALUES (G'<AB>');

where AB is a valid string of KanjiEBCDIC multibyte characters, G specifies the string must be in the Graphic repertoire, and each apostrophe is a single byte character.