This page is part of the book SQL-99 Complete, Really, by Peter Gulutzan & Trudy Pelzer. The authors have graciously allowed us to reproduce the contents of the book here. Because the book is about the SQL-99 standard, the contents of this and other pages in the book may not directly apply to MariaDB. Use the navigation bar to navigate the book.

In SQL, a bit string is either a binary bit string or a hexadecimal bit string. Binary bit strings are arbitrary sequences of zero or more binary digits (bits), each having a value of 0 or 1 and a length of 1 bit. Hexadecimal bit strings are arbitrary sequences of zero or more hexadecimal digits (hexits). A hexit is either (a) any of the digits 0 through 9 or (b) any of the letters A through F (upper case or lower case allowed) and is four bits long (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F are interpreted as 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110 and 1111, respectively). A bit string value may be a <literal>, the value of a parameter or a host language variable or the result of any expression or argument (including a possibly qualified <Column name>) that evaluates to a bit string.

A bit string has a length: a non-negative integer equal to the number of bits in the string. Bits in a bit string are numbered (from left to right), beginning with 1 (the most significant bit). Bit strings are stored in either of the two bit string <data type>s: BIT or BIT VARYING.