当数据库引擎用完用于主键的数字时,会发生什么? [英] What happens when DB engine runs out of numbers to use for primary keys?

查看:55
本文介绍了当数据库引擎用完用于主键的数字时,会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据库不会重复使用已删除记录的数量,可能会用完数量,尤其是如果您没有为该列选择真正大的整数类型。

会发生什么情况以及如何防止它

Since DBs do not reuse numbers of deleted records it is possible to run out of numbers, especially if you pick not really a big integer type for this column.
What would happen and how to prevent it if it's bad?

// SQL Server,MySQL //

// SQL Server, MySQL //

推荐答案

<我认为到底发生了什么取决于您使用的数据库引擎(MySQL中的INNODB和MyISAM之间甚至可能存在差异)。
无论发生什么事,它都不会很漂亮。

I think exactly what happens will be dependent on which database engine you're using (there may even be differences between INNODB and MyISAM in MySQL). Whatever happens, it's not going to be pretty.

您只需要将列类型更改为更大的整数即可。

You'd simply have to change the column type to a larger integer.

这篇关于当数据库引擎用完用于主键的数字时,会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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