Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report