16.20 - Hexadecimal Byte Literals - Teradata Vantage NewSQL Engine

Teradata Vantage™ Data Types and Literals

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1143-162K

Purpose

Declares a hexadecimal byte literal value.

Syntax



hexadecimal digits
A string of hexadecimal digits, where a hexadecimal digit is a character from 0 to 9, a to f, or A to F.
V
The hexadecimal literal is in byte variable format.
F
The hexadecimal literal is in byte fixed format. This is the default if F or V is not specified.

ANSI Compliance

Hexadecimal byte literals are Teradata extensions to the ANSI SQL:2011 standard.

Definition

Hexadecimal literals consist of 0 to 62000 hexadecimal digits delimited by a matching pair of apostrophes, where a hexadecimal digit is a character from 0 to 9, a to f, or A to F.

Data Types

The modifier following the XB determines the hexadecimal literal data type.

IF a hexadecimal literal uses this form … THEN the data type is …
'hexadecimal digits'XBV VARBYTE
'hexadecimal digits'XB

'hexadecimal digits'XBF

BYTE

Usage Notes

Hexadecimal byte literal is the only form for entering a byte string.

Rules

Hexadecimal byte literals are represented by an even number of hexadecimal digits. Hexadecimal literals are extended on the right with zeros when required.

Consider the following table:

CREATE TABLE bvalues (b1 BYTE(2));

Suppose you insert the hexadecimal byte literal 'C1C'XB into column b1:

INSERT bvalues ('C1C'XB);

The value is extended on the right with zeros:

SELECT * FROM bvalues;

b1
----
C1C0

Example: Hexadecimal Byte Literal

Suppose the column CodeVal has been defined as BYTE(2).

CREATE TABLE bvalues (IDVal INTEGER, CodeVal BYTE(2));

To insert a BYTE string as a hexadecimal literal, use the following form:

INSERT bvalues (112193, '7879'XB) ;

To select those rows from CodeVal, specify the conditional like this:

SELECT IDVal FROM bvalues WHERE CodeVal = '7879'XB ;