Get the App
SLTechnology News&Howtos  ›  Database  › 

The difference between & # 039 and & # 039 in MySQL and NULL in Innodb storage

Shulou Source: shulou.com Published: 2022-05-31 18:10:56 10月30日 Update

This article mainly introduces the difference between'',''in MySQL and NULL in Innodb storage. In daily operation, I believe many people have doubts about the difference between'',''in MySQL and NULL in Innodb storage. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of'',''in MySQL and the difference between NULL in Innodb storage! Next, please follow the editor to study!

1. Test environment mysql > create table testn (a varchar (20), b varchar (20)); Query OK, 0 rows affected (0.43 sec) mysql > insert into testn values ('', 'gaopeng'); Query OK, 1 row affected (0.08 sec) mysql > insert into testn values (', 'gaopeng'); Query OK, 1 row affected (0.12 sec) mysql > insert into testn values (NULL,'gaopeng'); Query OK, 1 row affected (0.08 sec) mysql > commit;Query OK, 0 rows affected (0.00 sec)

We see that there are three lines and three cases, which we will analyze respectively below.

2. Analysis

First line insert into testn values (', 'gaopeng')

The original storage is as follows:

070000000010002200000014061c000000002fe5bb0000016e011067616f70656e67

07: variable length of the second field 7

00: variable length of the first field 0

00: NULL bitmap has no NULL field

0000100022 5 byte fixed

00000014061c ROWID

000000002fe5 TRX ID

Bb0000016e0110 ROLL PTR

The first field has no stored character''

67616f70656e67: the second field, 'gaopeng'

Second line: insert into testn values ('', 'gaopeng')

The original storage is as follows:

070100000018002200000014061d000000002fe6bc0000017901102067616f70656e67

07: variable length of the second field 7

01: variable length of the first field 1

00: NULL bitmap has no NULL field

0000180022 5 byte fixed

00000014061d ROWID

000000002fe6 TRX ID

Bc000001790110 ROLL PTR

20: empty character''

67616f70656e67: the second field, 'gaopeng'

Line 3: insert into testn values (NULL,'gaopeng')

The original storage is as follows:

0701000020ffac00000014061e000000002febbf0000017c011067616f70656e67

07: variable length of the second field 7

A 01:NULL bitmap of 00000001 indicates that the first field is NULL

000020ffac:5 byte fixed

00000014061e ROWID

000000002feb TRX ID

Bf0000017c0110 ROLL PTR

The first field, NULL

67616f70656e67: the second field, 'gaopeng'

III. Summary

'' does not store, but will record a variable length of 0 zero null bitmap standard of 0.

NULL does not actually store and does not record variable length, but the NULL bitmap standard is 1.

'' do the storage as 0X20, the record variable length is 01 and the bitmap standard is 0.

At this point, the study on the difference between'',''in MySQL and NULL in Innodb storage is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Fields storage length variable bitmap learning original byte standard more help practical next line character actual situation article method environment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker NVidia Shulou Technology Microsoft