MySQL;大量数据的最佳数据类型 [英] MySQL ; Best data type for large numbers

查看:82
本文介绍了MySQL;大量数据的最佳数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想存储一个字段,该字段将每天的频道点击次数(每秒增加一次并在一天中更新)存储到 MySQL 数据库表中.请记住,我应该为列分配什么数据类型,甚至小于100 ,甚至超过一百万.

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.

推荐答案

MySQL

定点类型(精确值)-DECIMAL ,NUMERIC :

在标准SQL中,语法DECIMAL(M)等效于DECIMAL(M,0). 同样,语法DECIMAL等效于DECIMAL(M,0),其中 允许实现来确定M的值.MySQL支持 这两种DECIMAL语法的变体形式. M的默认值 是10.

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.

如果小数位数为0,则DECIMAL值不包含小数点或 小数部分.

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

DECIMAL的最大位数为65,但实际范围 对于给定的DECIMAL列,可以通过精度或 给定列的比例.当给这样的列分配一个值时, 小数点后的位数多于 指定的比例,值将转换为该比例. (精确 行为是特定于操作系统的,但通常效果是 截断为允许的位数.

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.)

存储要求:

这篇关于MySQL;大量数据的最佳数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆