, Many rows are deleted between 15 and 44, but those between 45 and 46 are not placed between 15 and 44, while those between 46 and 50 are deleted by the following, fill back, why? And before 51? Then, there should be three vacancies between 46 and 50, but it is filled...
, Many rows are deleted between 15 and 44, but those 45 and 46 are not placed between 15 and 44,
The location between 46 and 50 was filled back by the 52,51 behind the deletion. Why? And before 51?
Then, there should be three vacant spaces between 46 and 50, but the space is filled with two spaces, and the 53 behind them goes to the 50 s. Why?
.................
According to your answers, it seems that I have not made it clear.
I did not ask why it was not 16 after 15, but why did go before 52 ??
Reply content:
, Many rows are deleted between 15 and 44, but those 45 and 46 are not placed between 15 and 44,
The location between 46 and 50 was filled back by the 52,51 behind the deletion. Why? And before 51?
Then, there should be three vacant spaces between 46 and 50, but the space is filled with two spaces, and the 53 behind them goes to the 50 s. Why?
.................
According to your answers, it seems that I have not made it clear.
I did not ask why it was not 16 after 15, but why did go before 52 ??
Auto-increment is not necessarily related to data deletion. The auto-increment ID has its own sequence, not the largest id + 1 in the table.
Auto-increment IDs are added according to the maximum value that has occurred, no matter whether you delete them or not.
MySQL stores such a maximum value for each auto-increment column, instead of finding the maximum value in the table each time.
Efficiency problems, think about it ......
In addition, serial numbers are meaningful and can be referred to the basic principles of database design.
Each sequence number corresponds to a specified thing.
This design can also avoid confusion due to incomplete deletion (such as ID-related columns in another table but not deletion.
Last ......
I have many years of experience and will not delete anything that can be deleted.
Integrity, recoverability, data mining ......
Adding a column as a tag (indicating whether it is valid) is better than the deletion design.
PS: It seems that you have not understood the problem ......
The sorting problem depends on your SQL. If you care about the order, writeOrder.
Order
Otherwise, mysql only displays data according to its rules. If you do not specify a rule, do not expect it to comply with the rules you want.
Is data inserted sorted?
1. Auto-increment id refers to auto-increment when writing a table, instead of deleting a row like excel, which is automatically moved up downstream.
2. The sequence is incorrect. Why didn't you execute sort? Or by another field sort?