Home > Back-end >  The 2020-12-02: mysql, there is ID on the primary key table, and when the insert after 17 records de
The 2020-12-02: mysql, there is ID on the primary key table, and when the insert after 17 records de

Time:12-03

2020-12-02: mysql, there is ID on the primary key table, and when the insert after 17 records deleted 15,16,17 records, the mysql restart again, and then insert a record, the record ID is 18 or 15? # # f greatly architects a daily topic

CodePudding user response:

18 ~ are controlled by the built-in sequence, in the case of sequence under ~ down are in order

CodePudding user response:

ID on the primary key, 18

CodePudding user response:

If you are using the InnoDB engine, and in 8 version used to record the ID is 15, because InnoDB will reduce the maximum ID write into memory, if it is version 8.0 and later is to be written to the log, so the record is 18,

If you are using MylSAM engine, record is 18, because MylSAM will biggest ID recorded data file,

CodePudding user response:

15 a word count

CodePudding user response:

Old version is 18, unless you use SQL modification, the new version is not clear

CodePudding user response:

18, this is a function of growth ID, whether you delete or not delete

CodePudding user response:

Using the MylSAM engine, record is 18

CodePudding user response:

The situation is more complex, the first maintenance since the AUTO_INCREMENT primary key id value is increasing in the memory, this is a major premise, so you delete table data is useless and AUTO_INCREMENT value did not change, but if you restart the database AUTO_INCREMENT value will be changed, is equal to the table after the restart of the biggest AUTO_INCREMENT (select Max (id) maxId from table, after the AUTO_INCREMENT + 1, (InnoDB engine)
Of course there are exceptions, if your mysql is lower than 8.0, the database engine is MyISAM, that whether you delete or restart, AUTO_INCREMENT will not change, this should be a bug, version 8.0 give up using MyISAM engine,

CodePudding user response:

This is 18

CodePudding user response:

In the new Navicat measurement, reinsert id is 18, instead of 15