An increment table inside a total of seven data, delete the last two data, restart the MySQL database, and insert a piece of data, this time id is a few? How to get the current version of the database?

An increment table inside a total of seven data, delete the last two data, restart the MySQL database, and insert a piece of data, this time id is a few?

  In general, the type of table we created is InnoDB, (without restarting mysql case) If you add a record, id this record is 8; however, if the restart (mentioned in) MySQL, then this record the ID is 6. Because InnoDB tables only the maximum increment primary key ID record into memory, the database or table OPTIMIZE restart operation will cause the maximum loss ID.

However, if we use the table type MylSAM, then this record ID is 8. Because the MylSAM table will auto-increment primary key ID largest recorded in the data file which, after the restart MYSQL, the largest increment primary key ID will not be lost.

Note: If a deleted record in which the seven recording several intermediate (such as deleting a record two 3,4), after restarting the MySQL database, insert after a record, ID is 8. Because memory or database files are stored maximum increment primary key ID

How to get the current version of the database?

Use select version () to get the current version of the MySQL database.

Guess you like

Origin www.cnblogs.com/jxxblogs/p/12162717.html