Go to the first, previous, next, last section, table of contents.


Choosing the right type for a column.

Try to use the most precise type in all cases. For example for an integer between 1-99999 a unsigned mediumint is the best type.

A common problem is representing monetary values accurately. In MySQL you should use the DECIMAL type. This is stored as a string so no loss of accuracy should occur. If accuracy is not to too important the DOUBLE type may also be good enough.

For high precision you can always convert to a fixed point type stored in a BITINT. This allows you to do all calculations with integers and only convert the result back to floating point.

See section What are the different row formats? Or when to use VARCHAR/CHAR?.


Go to the first, previous, next, last section, table of contents.