MySQL ; Best data type for large numbers

流过昼夜 提交于 2020-01-11 03:03:05

问题


I want to store a field which stores channel clicks per day( increasing every second and updated in a day) into MySQL DB table. What datatype should I assign to the column keeping in mind that it can even be less than 100 or can even exceed a million.


回答1:


MySQL Integer Types (Exact Value):

Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC:

In standard SQL, the syntax DECIMAL(M) is equivalent to DECIMAL(M,0). Similarly, the syntax DECIMAL is equivalent to DECIMAL(M,0), where the implementation is permitted to decide the value of M. MySQL supports both of these variant forms of DECIMAL syntax. The default value of M is 10.

If the scale is 0, DECIMAL values contain no decimal point or fractional part.

The maximum number of digits for DECIMAL is 65, but the actual range for a given DECIMAL column can be constrained by the precision or scale for a given column. When such a column is assigned a value with more digits following the decimal point than are permitted by the specified scale, the value is converted to that scale. (The precise behavior is operating system-specific, but generally the effect is truncation to the permissible number of digits.)

Storage Requirements:




来源:https://stackoverflow.com/questions/39588762/mysql-best-data-type-for-large-numbers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!