当前位置:网站首页>How to store null value on the disk of yyds dry inventory?
How to store null value on the disk of yyds dry inventory?
2022-07-03 21:40:00 【Official account javaedge】
1 Why not save it directly NULL?
NULL List of values , The possible field values in a row of data are NULL, such as nickname Field , Allow for NULL, When the storage , If there is no assignment , The field value is NULL.
Suppose this field is NULL When the value is stored on disk , Is in accordance with the “NULL” String storage , Isn't it a waste of storage space and strange ?
2 How to store ?
Not through string , But through binary bit Bit storage , It is assumed that the values of multiple fields in a row of data are NULL, So the of these fields NULL, It'll take bit The bit form is stored in NULL List of values .
The following table :
CREATE
TABLE customer
(
name
VARCHAR
(
10
)
NOT
NULL
,
address
VARCHAR
(
20
)
, gender
CHAR
(
1
)
,
job
VARCHAR
(
30
)
,
school
VARCHAR
(
50
)
) ROW_FORMAT
=COMPACT
;
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
Yes 4 Variable length fields , There is also a fixed length field ,name Statement NOT NULL, other 4 All fields are possible NULL
How can the following row of data be stored on disk :
jack NULL m NULL xx_school
- 1.
There are two fields NULL
3 Disk storage format of a row of data
Think about the row of case data in the table above , How to store on disk , Because it has multiple variable length fields , Multiple fields are allowed to be NULL. First of all, let's review , The storage format of a row of data on disk should be as follows :
Variable length field length list
NULL List of values Header information column1
=value1 column2
=value2 ... columnN
=valueN
- 1.
4 Variable length fields , Put first in reverse order school Length of field , Put again job、address、name The value length of several fields ?
But there is one problem to distinguish , If this variable length field value is NULL, There is no need to store its value length in the variable length field length list , So the data in the above line , Only name and school Two variable length fields have values , Put their lengths in the variable length field length list in reverse order :
0x09
0x04
NULL List of values Header information column1
=value1 column2
=value2 ... columnN
=valueN
- 1.
All allowable values are NULL Field of , It doesn't have to be worth NULL, As long as it is allowed to NULL Field of , Each field has a binary bit A value :
- bit The value is 1 That is the NULL
- bit The value is 0 The explanation is not NULL
For example, above 4 Both fields are allowed to be NULL, Everyone will have one bit position , The value of this row of data is
jack NULL m NULL xx_school
- 1.
among 2 The fields are null,2 A field is not null, therefore 4 individual bit It should be :1010
But in fact NULL Value list , Put in reverse order , therefore NULL In the value list :0101, The overall data in this row is as follows :
0x09 0x04 0101 Header information column1=value1 column2=value2 ... columnN=valueN
- 1.
actual NULL When storing the value list , Generally at least 8 individual bit Multiple of bits , Insufficient 8 individual bit The high position is filled 0, So the actual storage is as follows :
0x09 0x04 00000101 Header information column1=value1 column2=value2 ... columnN=valueN
- 1.
4 How to read a row of data on the disk ?
Disk data storage format :
0x09 0x04 00000101 Header information column1=value1 column2=value2 ... columnN=valueN
- 1.
First reading :
- Variable length field length list
You know there are several variable length fields
- NULL List of values
Which variable length fields are NULL
From the variable length field length list, it is resolved that it is not NULL Value length of variable length field , Then you also know which fields are NULL. Based on this information , From the actual column value storage area , Read out the value of each field .
- Variable length field value , Just read by the length of the value , if NULL, I knew he was a NULL, No value stored
- Fixed length field , Read according to the fixed length
边栏推荐
- "Actbert" Baidu & Sydney University of technology proposed actbert to learn the global and local video text representation, which is effective in five video text tasks
- Luogu deep foundation part 1 Introduction to language Chapter 6 string and file operation
- A little understanding of GSLB (global server load balance) technology
- leetcode-540. A single element in an ordered array
- Custom view incomplete to be continued
- Analyse de REF nerf
- Visiontransformer (I) -- embedded patched and word embedded
- MySQL——数据库备份
- Getting started with postman -- built-in dynamic parameters, custom parameters and assertions
- MySQL——规范数据库设计
猜你喜欢

MySQL——JDBC

UI automation test: selenium+po mode +pytest+allure integration

Station B, dark horse programmer, employee management system, access conflict related (there is an unhandled exception at 0x00007ff633a4c54d (in employee management system.Exe): 0xc0000005: read locat

Pengcheng cup Web_ WP

Advanced collaboration: coroutinecontext

UC Berkeley proposes a multitask framework slip

Hcie security Day11: preliminarily learn the concepts of firewall dual machine hot standby and vgmp

技术管理进阶——如何在面试中考察候选人并增大入职概率

常用sql集合

Nmap and masscan have their own advantages and disadvantages. The basic commands are often mixed to increase output
随机推荐
[secretly kill little buddy pytorch20 days -day02- example of image data modeling process]
Hcie security Day12: supplement the concept of packet filtering and security policy
Qualcomm platform WiFi update disconnect end open event
Service discovery and load balancing mechanism -service
gslb(global server load balance)技术的一点理解
What is the content of the securities practice examination?
"Designer universe" argument: Data Optimization in the design field ultimately falls on cost, safety and health | chinabrand.com org
Link aggregation based on team mechanism
Hcie security Day10: six experiments to understand VRRP and reliability
[vulnhub shooting range] impulse: lupinone
Minio deployment
Advanced technology management - how to examine candidates in the interview and increase the entry probability
gslb(global server load balance)技術的一點理解
Getting started with DOM
Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
MySQL——JDBC
Qualcomm platform WiFi -- P2P issue
仿网易云音乐小程序
treevalue——Master Nested Data Like Tensor
Nmap and masscan have their own advantages and disadvantages. The basic commands are often mixed to increase output