<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="choosing-types">
      </a>
      13.8 Choosing the Right Type for a Column
     </h2>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045210391008">
  </a>
  <a class="indexterm" name="idm46045210389552">
  </a>
  <p>
   For optimum storage, you should try to use the most precise type
      in all cases. For example, if an integer column is used for values
      in the range from
   <code class="literal">
    1
   </code>
   to
   <code class="literal">
    99999
   </code>
   ,
   <code class="literal">
    MEDIUMINT UNSIGNED
   </code>
   is
      the best type. Of the types that represent all the required
      values, this type uses the least amount of storage.
  </p>
  <p>
   All basic calculations (
   <code class="literal">
    +
   </code>
   ,
   <code class="literal">
    -
   </code>
   ,
   <code class="literal">
    *
   </code>
   , and
   <code class="literal">
    /
   </code>
   ) with
   <a class="link" href="fixed-point-types.html" title="13.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC">
    <code class="literal">
     DECIMAL
    </code>
   </a>
   columns are done with precision of 65 decimal (base 10) digits.
      See
   <a class="xref" href="numeric-type-syntax.html" title="13.1.1 Numeric Data Type Syntax">
    Section 13.1.1, “Numeric Data Type Syntax”
   </a>
   .
  </p>
  <p>
   If accuracy is not too important or if speed is the highest
      priority, the
   <a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
    <code class="literal">
     DOUBLE
    </code>
   </a>
   type may be
      good enough. For high precision, you can always convert to a
      fixed-point type stored in a
   <a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
    <code class="literal">
     BIGINT
    </code>
   </a>
   . This enables you to do all
      calculations with 64-bit integers and then convert results back to
      floating-point values as necessary.
  </p>
 </div>
 <br/>
</div>
