In the game industry, often encounter the need to delete the "dead number", our user ID is generated, in the deletion program, you will encounter with the database disconnected, but still running SQL statements;
For the increment of the field to delete the row records, there will be "fault zone" situation, for this unavoidable situation, personal advice in the data maintenance process, analyze table to prevent excessive data storage debris;
The old ID is not reused for the new self ID; The following lists the different storage engine support for auto_increment:
for innodb,myisam,memory storage engines;
Common:
1, the sequence is monotonically increasing;
2, the number is incremented sequentially, will not reuse the ID that has been deleted
3, can set the initial value of the ID;
4, TRUNCATE TABLE after the count value starting from 1;
5, the table can only have one field is the self-added field;
Different points:
MyISAM supports the inclusion of a self-adding sequence in the composite Index; InnoDB and memory are not supported;
For the two parameters that are added (for multiple master scenarios, pay more attention to these two parameters):
Auto_increment_offset: Determine the starting value of the self-added field
Auto_increment_increment: Increment of value change
If the value of the Auto_increment_offset is greater than the Auto_increment_increment value, the Auto_increment_offset value is ignored.
This article is from the "Technology Achievement Dream" blog, please be sure to keep this source http://weipengfei.blog.51cto.com/1511707/1213939
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/