Alter table causes auto_increment resequencing, resulting in duplicate entry '1' for key 'Primary ',

Source: Internet
Author: User

Alter table causes auto_increment resequencing, resulting in duplicate entry '1' for key 'Primary ',

When you open the navicat design table and want to change the primary key id to auto-increment, this prompt will pop up. Changing the table will lead to auto-increment (column) re-sorting, and the primary key will have repeated '1 '. The reason is that auto_increment is auto-incrementing from 1. If a record with id = 0 and id = 1 exists at the same time, it will change id = 0 to id = 1, so the two methods conflict.

Truncate table name and delete from tablename: the former clears data and id sorting records, and the primary key starts from 0; the suffix only clears data, do not clear the id sorting record primary key and continue accumulating from the empty position.

Related Article

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.