空值是否可以节省存储空间? [英] Do null values save storage space?

查看:182
本文介绍了空值是否可以节省存储空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

数据库中空值使用的空间

有效的存储空间?


  • A nullable int

  • 一个 int 列满零。

  • A nullable int column full of nulls.
  • An int column full of zeroes.

我知道可空列会占用1个额外的信息位来存储它的空状态,但是为空值保存数据库,为空的int分配32位。

I know a nullable column takes up 1 extra bit of information to store its null state, but do null values save the database from allocating 32 bits for an int that is null?

(null语义和null的意义对此问题不重要)

(null semantics and the meaning of null are not important for this question)

推荐答案

nullable int所需的存储空间总是相同的,无论值是否为null。

For fixed width fields like nullable int the storage space required is always the same regardless of whether the value is null or not.

对于可变宽度可空字段,值NULL需要零字节的存储空格(忽略该位以存储该值是否为null)。

For variable width nullable fields the value ’NULL‘ takes zero bytes of storage space (ignoring the bit to store whether the value is null or not).

这篇关于空值是否可以节省存储空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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