A <bit string literal> is either a binary <bit string literal> or a hexadecimal <bit string literal>.
binary <bit string literal>:
A binary <bit string literal> is the letter "B" (upper case mandatory)
followed by a string of zero or more bits inside a pair of single quote marks.
Its <data type> is fixed length BIT, though it is compatible with both the BIT
and the BIT VARYING <data type>s. The <literal>'s length is the number of bits
inside the quote marks; the delimiting single quotes aren't part of the
<literal>, so they're not included in the calculation of the <bit string
literal>'s size. Here are some examples of binary <bit string literal>s:
B'00010110' B'1101'
Hexadecimal <bit string literal>:
A hexadecimal <bit string literal> is the letter "X" (upper case mandatory)
followed by a string of zero or more hexits inside a pair of single quote
marks. Its <data type> is fixed length BIT, though it is
compatible with both the BIT and the BIT VARYING
<data type>s. The <literal>'s length is four times the number of hexits inside
the quote marks; the delimiting single quotes are not part of the <literal>,
therefore they are not included in the calculation of the <bit string
literal>'s size. Here are some examples of hexadecimal <bit string literal>s:
X'49FE' X'a31d'
[Obscure Rule] SQL allows you to break a long <bit string literal> up into two or more smaller <bit string literal>s, split by a <separator> that includes a newline character. When it sees such a <literal>, your DBMS will ignore the <separator> and treat the multiple strings as a single <literal>. For example, these two <bit string literal>s are equivalent:
B'00001111' '01101100' B'0000111101101100'
(In the first example, there is a carriage return newline <separator> between "1111'" and "'0110".)
These two <bit string literal>s are also equivalent:
X'09AF' 'ab42' X'09afAB42'
If you want to restrict your code to Core SQL, do not use either binary or hexadecimal <bit string literal>s.
Note:
Portions of the text in this entry are Copyright © 1999 by Ocelot Computer Services Incorporated. Used by permission.