The NULL value in MySQL represents unknown or non-existent and is stored as a 1-bit bit field flag located at the end of each column data value. This storage scheme efficiently represents NULL values with only 1 bit, allowing fast checking and reducing storage space.
Storage of NULL in MySQL
The meaning of NULL
In MySQL, NULL represents an unknown or non-existent value, the same concept as in the SQL standard.
Storage scheme
MySQL does not store NULL values directly. Instead, it uses a special value to represent NULL, called a bit-field marker (bit-field marker).
bit-field marker is a 1-bit value stored at the end of each column in the table. When the value is 0, it means that the value of the column exists; when the value is 1, it means that the value of the column is NULL.
Storage structure
As shown below, the space allocated for each column contains data values and bit-field markers:
<code>| 数据值 | bit-field marker |</code>
Efficiency Optimization
MySQL uses bit-field marker to represent NULL, which is an efficient storage solution because it:
The above is the detailed content of How to store null in mysql. For more information, please follow other related articles on the PHP Chinese website!