Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>DOUBLE columns are <strong>not</strong> the same as DECIMAL columns, and you <strong>will get in trouble</strong> if you use DOUBLE columns for financial data.</p> <p>DOUBLE is actually just a double precision (64 bit instead of 32 bit) version of <a href="http://en.wikipedia.org/wiki/Floating_point" rel="noreferrer">FLOAT</a>. Floating point numbers are approximate representations of <a href="http://en.wikipedia.org/wiki/Real_number" rel="noreferrer">real numbers</a> and they are not exact. In fact, simple numbers like 0.01 do not have an exact representation in FLOAT or DOUBLE types.</p> <p>DECIMAL columns are exact representations, but they take up a lot more space for a much smaller range of possible numbers. To create a column capable of holding values from 0.0001 to 99.9999 like you asked you would need the following statement</p> <pre><code>CREATE TABLE your_table ( your_column DECIMAL(6,4) NOT NULL ); </code></pre> <p>The column definition follows the format DECIMAL(M, D) where <em>M</em> is the maximum number of digits (the <em>precision</em>) and <em>D</em> is the number of digits to the right of the decimal point (the <em>scale</em>). </p> <p>This means that the previous command creates a column that accepts values from -99.9999 to 99.9999. You may also create an UNSIGNED DECIMAL column, ranging from 0.0000 to 99.9999.</p> <p>For more information on MySQL DECIMAL the <a href="http://dev.mysql.com/doc/refman/5.1/en/precision-math-decimal-characteristics.html" rel="noreferrer">official docs</a> are always a great resource.</p> <p>Bear in mind that all of this information is true for versions of MySQL 5.0.3 and greater. If you are using previous versions, you really should upgrade.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload