Declares a hexadecimal byte literal value.
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 |
ANSI Compliance
Hexadecimal byte literals are Teradata extensions to the ANSI SQL:2011 standard.
Syntax
'hexadecimal digits' XB [ V | F ]
Syntax Elements
- 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.
Usage Notes
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
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 ;