<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="bit-type">
      </a>
      13.1.5 Bit-Value Type - BIT
     </h3>
    </div>
   </div>
  </div>
  <p>
   The
   <code class="literal">
    BIT
   </code>
   data type is used to store bit
        values. A type of
   <code class="literal">
    BIT(
    <em class="replaceable">
     <code>
      M
     </code>
    </em>
    )
   </code>
   enables
        storage of
   <em class="replaceable">
    <code>
     M
    </code>
   </em>
   -bit values.
   <em class="replaceable">
    <code>
     M
    </code>
   </em>
   can range from 1 to 64.
  </p>
  <p>
   To specify bit values,
   <code class="literal">
    b'
    <em class="replaceable">
     <code>
      value
     </code>
    </em>
    '
   </code>
   notation
        can be used.
   <em class="replaceable">
    <code>
     value
    </code>
   </em>
   is a binary value
        written using zeros and ones. For example,
   <code class="literal">
    b'111'
   </code>
   and
   <code class="literal">
    b'10000000'
   </code>
   represent 7 and 128, respectively. See
   <a class="xref" href="bit-value-literals.html" title="11.1.5 Bit-Value Literals">
    Section 11.1.5, “Bit-Value Literals”
   </a>
   .
  </p>
  <p>
   If you assign a value to a
   <code class="literal">
    BIT(
    <em class="replaceable">
     <code>
      M
     </code>
    </em>
    )
   </code>
   column that
        is less than
   <em class="replaceable">
    <code>
     M
    </code>
   </em>
   bits long, the value
        is padded on the left with zeros. For example, assigning a value
        of
   <code class="literal">
    b'101'
   </code>
   to a
   <code class="literal">
    BIT(6)
   </code>
   column is, in effect, the same as assigning
   <code class="literal">
    b'000101'
   </code>
   .
  </p>
  <p>
   <b>
    NDB Cluster.
   </b>
   The maximum combined size of all
   <code class="literal">
    BIT
   </code>
   columns used in a given
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDB
    </code>
   </a>
   table
          must not exceed 4096 bits.
  </p>
 </div>
 <br/>
</div>
