如果达到限制,数据库如何处理自动编号字段?

发布于 2024-09-03 14:07:23 字数 121 浏览 1 评论 0原文

在我的表中,我选择了 id 列的类型为 int (4 字节)。我想知道的答案是,一旦达到限制,任何数据库将如何处理它?数据库会拒绝在表中插入更多记录吗?或者到底会发生什么?另外我应该如何解决此类问题(如果数据库本身不能处理它)?

In my tables, i have selected id column to be of type int (4 bytes). The answer i want to know is how will any database handle it once it's limits are reached? Will the database refuse to insert any more records in table? or what exactly will happen? Also how should i tackle this type of problem (if the database doesn't handle it by itself)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

定格我的天空 2024-09-10 14:07:23

我很想知道您所说的“数据库”是什么。但通常这是一个错误。那么数据库就满了。您应该提供一些“压缩”主键的方法,或者更简单:

使用长整数作为键(8 字节)。即使从现在开始每秒插入 1000 个项目,这也会持续近 3 亿年。在这种情况下,4 字节整数(带符号)仅持续 24 天。

I would love to know what you refer to as "the" database. But usually it is an error. The database is full then. You should provide some means for "compacting" the primary key then, or more easy:

Use long integers as keys (8 bytes). Even if you insert 1000 items per second from now on, this will last for nearly 300 million years. The 4 byte integer (signed) will only last for 24 days in this scenario.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文