Introduction to MySQL auto_increment properties

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.