Space used by nulls in database

前端 未结 6 1554
深忆病人
深忆病人 2020-12-03 13:32

If a column is null, does that affect the space used by the column? Is the space used fixed by the column definition? Does this vary from database to database. (I am mainly

6条回答
  •  渐次进展
    2020-12-03 14:05

    It's stored in a bitmap, not as a column value.

    Example: a nullable varchar column called middle name

    • row 1, "bob" is stored as an offset, 3 bytes for bob, 2 bytes for length of "bob"
    • row 2, NULL row is not stored as a value like "bob", but in the row header

    Unless you have a very small table, say a single column char(1), then it's more efficient

    Link 1 Link 2

提交回复
热议问题