SQL Server 2008:如果身份超过int的最大值,会发生什么情况?

想象一下,我们有一张桌子:

create table MYTABLE ( id int IDENTITY(1,1) ,name varchar(10) ) 

我们必须在表格中插入很多行。

有人知道当生成的标识值超过最大整数值(2 ^ 32-1)时会发生什么?

  1. 你会得到以下错误:

    Msg 8115, Level 16, State 1, Line 1
    Arithmetic overflow error converting IDENTITY to data type int.
    Arithmetic overflow occurred.

  2. 您将无法插入更多logging,直到您:

    • 删除一些并使用DBCC CHECKIDENT命令重置身份列,
      要么
    • 将列的数据types更改为bigint (由GabrielGuimarãesbuild议)。