How are NULLs stored in a database?

后端 未结 5 834
野性不改
野性不改 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:42

    MySql uses the second method. It stores an array of bits (one per column) with the data for each row to indicate which columns are null and then leaves the data for that field blank. I'm pretty sure this is true for all other databases as well.

    The problem with the first method is, are you sure that whatever value you select for your data won't show up as valid data? For some values (like dates, or floating point numbers) this is true. For others (like integers) this is false.

提交回复
热议问题