MySQL:NULL字段使用多少空间? [英] MySQL: How much space does a NULL field use?
问题描述
将数据设为NULL会节省任何内存而不是其正常大小吗?
Does making a datum NULL save any memory versus its normal size?
推荐答案
This is discussed in the MySQL manual chapter on Storage Requirements. There is no simple answer; it depends on the data type of the column, whether the column is indexed; and the storage engine. The impact of using NULL for a column can vary from nothing to several bytes (depending on how many other columns are also NULL-able.)
将列声明为接受NULL并实际存储NULL值对存储的影响可能很小.包含大量NULL值的列通常表示需要(进一步)规范化.
The storage impact of declaring a column as accepting NULL, and of actually storing a NULL value, is probably minor. Having a column with lots of NULL values often indicates a need for (further) normalization.
基本规则是,根据数据的属性而不是对存储的影响来设计架构.仅在发现问题时才进行修复.
The basic rule is, design your schema based on the properties of the data, not on the storage impact. Fix things only if they turn out to be a problem.
这篇关于MySQL:NULL字段使用多少空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!