当自动递增列用尽时会发生什么? [英] What happens when an auto-incrementing column runs out?

查看:193
本文介绍了当自动递增列用尽时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑一个带有自动增量列的简单表,如下所示:

Consider a simple table with an auto-increment column like this:

CREATE TABLE foo 
(
  `fooid` bigint unsigned NOT NULL auto_increment,
   ....snipped.... other columns
  PRIMARY KEY (`fooid`)
) 
ENGINE=InnoDB AUTO_INCREMENT=10

如何重新设计这个,以便我们没有达到bigint数据类型的最大值?
无符号范围是0到18446744073709551615.
我不知道需要多长时间才能达到18446744073709551615,但像Y2K问题一样,我想为此准备好。

How does one redesign this so that we don't hit the max of the bigint datatype ? The unsigned range is 0 to 18446744073709551615. I don't know how long it will take to reach 18446744073709551615, but like the Y2K problem, I want to be ready for it.

推荐答案

假设您每毫秒插入一行。

Suppose you insert one row every millisecond.

18446744073709551615 millseconds =
18446744073709552秒=
307445734561826分钟=
5124095576030小时=
213503982335天=
584942417年

18446744073709551615 millseconds = 18446744073709552 seconds = 307445734561826 minutes = 5124095576030 hours = 213503982335 days = 584942417 years

所以这不是真的像Y2K问题

So it's not really like the Y2K problem

你可以插入

换句话说:不用担心。

这篇关于当自动递增列用尽时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆