What happens when AUTO_INCREMENT reaches the maximum value?

2019-12-09 23:48:47 Trisha Laravel

When AUTO_INCREMENT reaches the maximum value in Mysql

If the AUTO_INCREMENT column allows only unique values ??such as a primary key

? An error occurs due to duplication (unique constraint violation).

If the AUTO_INCREMENT column allows duplicate values

? After the maximum value, the maximum value is assigned consecutively.

If the column with AUTO_INCREMENT set in MySQL reaches the maximum value, the same value as the maximum value is automatically assigned after that. Therefore, if a primary key that does not allow duplication of AUTO_INCREMENT is set, key duplication occurs during INSERT, and an error such as ERROR 1062 (23000): Duplicate entry '***' for key 'PRIMARY' occurs. If the AUTO_INCREMENT column allows duplicates, after reaching the maximum value, the row is inserted with the same value as the maximum value.

Please note: You cannot set up circular sequences like MySQL with the CYCLE option in MySQL.

This post is submitted by one of our members. You may submit a new post here.

Related Tricks