MySQL: Size of decimal data type

前端 未结 2 1582
深忆病人
深忆病人 2021-01-04 02:32

I have a few values that come in from a server that need to be stored in my database. I\'m not a MySQL expert, but I understand it well enough for basic input/output. Right

2条回答
  •  一生所求
    2021-01-04 03:06

    From MySQL:

    The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments in MySQL 5.1 are as follows:

    M is the maximum number of digits (the precision). It has a range of 1 to 65. (Older versions of MySQL permitted a range of 1 to 254.)

    D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.

    Consider this number: 123456789.12345 here M is 14 and D is 5 then based on this principle you can set DECIMALS(M,D) for each column based on Their expected maximum values.

提交回复
热议问题