How are NULLs stored in a database?

后端 未结 5 824
野性不改
野性不改 2021-01-04 11:25

I\'m curious to know how NULLs are stored into a database ?

It surely depends on the database server but I would like to have an general idea about it.


5条回答
  •  长发绾君心
    2021-01-04 11:49

    On PostgreSQL, it uses an optional bitmap with one bit per column (0 is null, 1 is not null). If the bitmap is not present, all columns are not null.

    This is completely separate from the storage of the data itself, but is on the same page as the row (so both the row and the bitmap are read together).

    References:

    • http://www.postgresql.org/docs/8.3/interactive/storage-page-layout.html

提交回复
热议问题