Default size of datatype float in mysql - phpmyadmin

12,086

As mysql manual on float says:

For maximum portability, code requiring storage of approximate numeric data values should use FLOAT or DOUBLE PRECISION with no specification of precision or number of digits.

No length is the default length value.

However, if you do specify length, then mysql will round the float to the number of decimals specified. See the documentation linked above for more details:

For example, a column defined as FLOAT(7,4) will look like -999.9999 when displayed. MySQL performs rounding when storing values, so if you insert 999.00009 into a FLOAT(7,4) column, the approximate result is 999.0001.

Share:
12,086
user9050678
Author by

user9050678

Updated on June 26, 2022

Comments

  • user9050678
    user9050678 over 1 year

    I have many float columns, But in phpmyadmin I didn't provide the size of float but unlike varchar, it still saves the column enter image description here

    1. what is the default size of float?

    2. should I enter the size manually like Float(10,2) Or it does not make much performance difference ?

    Thanks :)