Get the App
SLTechnology News&Howtos  ›  Database  › 

The solution of self-increasing ID of MySQL to reach the upper limit

Shulou Source: shulou.com Published: 2022-06-01 17:15:00 09月10日 Update

What if MySQL self-adding ID runs out?

There are many types of self-increasing ID in MySQL. Each self-increasing ID sets the initial value, and then increases according to a certain step. As long as the byte length is defined, there will be an upper limit. If the upper limit is added again, a primary key conflict error will be reported, and the solution can consider using the "bigint unsigned" type.

test

The self-increasing ID defined by the datasheet, if the upper limit is reached.

When you apply for the next ID, the value you get will remain unchanged.

We can verify it with the following example:

Create table `test` (`id` int (10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=4294967295; insert into `test` values (null)

You can see from this result that the ID value was still 4294967295 when the data was first inserted.

When the data is inserted for the second time, a primary key conflict error is reported.

This means that after the ID value reaches the upper limit, it will not change again.

What if the MySQL self-adding ID runs out? For more details, please pay attention to other related articles!

Tags: Upper limit data done what to do time type error conflict method content again can pass byte that is datasheet article more first time result or Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno Xiaomi Linux MariaDB