When using decimal in MySQL, does a value of
(5,3) make it so the max number is
99.999? If not how do I specify that? My number is for currency so I need to use decimal, but it should not go over 99 and it must have 3 decimal places.
decimal (5,3) is the standard SQL way to define a field with a range of
-99.999 .. 99.999.
Note that with MySQL, if you attempt to insert a value that is out of range, MySQL will automatically truncate the value to the nearest boundary value (in this case, either 99.999 or -99.999) without throwing an error.
In this case, there will be a maximum of
5 digits of data stored, with exactly
3 digits to the right of the decimal point. If you insert a number like
1.23 it will be stored as
1 will be stored as
1.000. If you insert
12.3456 it will be rounded up to
12.346; if you insert
12.0001 it will be rounded down to
When the column is returned to your program, the exact representation will depend upon how your database API maps a decimal data type. If it maps to an integer, you'll lose the decimal fraction; if it maps to a floating point number (float, double), you may lose precision; if it maps to a Decimal (C#/Java) then you'll get an exact representation, as long as your value is within the bounds of the datatype.
The method you specified should work. I don't see any problems with it.