MySQL self-increment ID start value modified

Source: Internet
Author: User

Many friends in MySQL think that the field auto_increment type self-increment ID value can not be modified, in fact, this understanding is wrong, the following describes the MySQL self-increment ID starting value modification and setting method.
The usual way to set the self-increment field:
Add when creating a table:


key,...)


After creating the table, add:


Key key.


Many times you want the ID of the data in the table not starting from 1, like QQ, ID starting from 10000
The code is as follows:


ALTER TABLE users auto_increment=10000;

And the statement also applies to modify the ID of an existing table, such as large batches of deleted data, the ID from 654321 to 123456 start

ALTER TABLE users auto_increment=123456;

MySQL self-increment ID start value modified

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.