15.10 - Hexadecimal Byte Literals - Teradata Database

Teradata Database SQL Data Types and Literals

prodname
Teradata Database
vrm_release
15.10
category
Programming Reference
featnum
B035-1143-151K

Declares a hexadecimal byte literal value.

where:

 

This syntax element …

Specifies …

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.

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

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.

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

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

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

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 ;