在 SQL Server 上:这取决于 RID 列的类型。内部 IDENTITY 可以递增,但无法分配给 stoarge 列:
CREATE TABLE [t1] (
[tid] int IDENTITY (2147483647, 1) NOT NULL
, name varchar(1)
) ON [PRIMARY]
GO
insert into t1(name) values('1')
insert into t1(name) values('1')
这会触发错误:
Msg 8115, Level 16, State 1, Line 2
Arithmetic overflow error converting IDENTITY to data type int.
Arithmetic overflow occurred.
但是具有足够存储空间的数字列会很好地增加:
CREATE TABLE [t1] (
[tid] numeric(38,0) IDENTITY (2147483647, 1) NOT NULL
, name varchar(1)
) ON [PRIMARY]
GO
insert into t1(name) values('1')
insert into t1(name) values('1')
同样,一个 bigint 将在 2^^63-1 处溢出:
CREATE TABLE [t1] (
[tid] bigint IDENTITY (9223372036854775807, 1) NOT NULL
, name varchar(1)
) ON [PRIMARY]
GO
insert into t1(name) values('1')
insert into t1(name) values('1')
但是具有足够存储空间的数字列会成功:
CREATE TABLE [t1] (
[tid] numeric(38,0) IDENTITY (9223372036854775807, 1) NOT NULL
, name varchar(1)
) ON [PRIMARY]
GO
insert into t1(name) values('1')
insert into t1(name) values('1')