In our daily work, we will carry out CRUD operations on the database. Generally, it is a certain data operation on a certain table in a certain library. So what are we manipulating behind the data?
In fact, the concept of libraries and tables is only a physical concept, in fact, all our operations are around the mysql created table file operation.
When we use create table A to create a table a, we create a table file named A. ibd on the server.
Data row structure
Data row format:
Variable length field NULL Header field Data 1 Data 2 Data 3
The structure in table A looks like this:
Alter table A insert into table A;
insert into a (name,id_card) values (’11’,’36666….. ‘);
This is what it looks like in the file
11 36666…
Since the name field is of vARCHar type, the length of the name field is variable. The specific length cannot be directly obtained like that of the char field, so it may be read as
1 1366666…
It can also be read as
11 366666…
So there needs to be a value in the data row that records the actual field length of the VARCHAR type field.
For example, if the value of the new name field is 11 and the length is 2, then the hexadecimal description is 0x02. With the description of the variable length field, the actual length value of a variable length field can be accurately obtained.
We also have null and non-null fields in our data. In the database, the binary notation is used to indicate whether it is null, with 0 indicating non-NULL and 1 indicating NULL
For example, the data in table A is 11,1366666….
So on disk the data actually looks like this:
0x02 00 Header Field 11 1366666……