Reference Guide > TDV SQL Support > Data Types > Binary Literals
 
Binary Literals
TDV supports the following literals:
Binary <bit string literal>
Hexadecimal <bit string literal>
Base 2 Binary Literal
Binary bit strings are arbitrary sequences of zero or more binary digits (bits), each having a value of 0 or 1.
Base 2 Binary Literal is a SQL literal that starts with a case insensitive “b”, immediately followed by a delimited string containing zero or one. For example - B'10101' or b’’ (where the string is empty).
Binary Length
The binary length will be the length of the string divided by 8. If string's length is less than 8, then the binary length is 1.
Note: The base 2 contents will be internally converted to base 16.
Base 16 Hexadecimal Literal
Hexadecimal bit strings are arbitrary sequences of zero or more hexadecimal digits (hexits). A hexit can be any of the digits (0-9) or any of the letters A-F (case insensitive).
Base 16 Hexadecimal is a SQL literal that starts with a case insensitive "x", immediately followed by a case insensitive delimited string 0-9a-z. For example - X'ABF' or x’’ (where the string is empty).
Binary Length
The binary length will be the length of the string divided by 2. If the string's length 1, then the binary length is 1.
0x Style
Binary literal can also start with a zero immediately followed by a x (case insensitive). For example:
0xBEEFDEAD
0XBADDAD
0X
Comparison of Literals
Binary literals can be compared. For example:
1. x'0A' = B'00001011' – Returns TRUE.
2. x'000A' = B'00001011' – Returns FALSE.
Note: TDV does not trim the leading zeros and hence x’000A’ is equivalent to BINARY(1) whereas x’0A’ is equivalent to BINARY(2).