Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report