加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 数据库 > MsSql > 正文

sql-server – SqlServer中autoincremental int主键的最大值

发布时间:2020-05-24 18:27:39 所属栏目:MsSql 来源:互联网
导读:有最大值吗? SQL Server会在达到最大值时开始抛出SqlExceptions吗? 你是如何解决的? (归档?) 从SQL Server资源我可以看到最大值为2,147,483,647.我离此很远,但我只是很好奇. 您可以使用这个小例子看到错误 use tempdb;if OBJECT_ID(dbo.test, U) is not n

有最大值吗?
SQL Server会在达到最大值时开始抛出SqlExceptions吗?
你是如何解决的? (归档?)

从SQL Server资源我可以看到最大值为2,147,483,647.我离此很远,但我只是很好奇.

解决方法

您可以使用这个小例子看到错误
use tempdb;

if OBJECT_ID('dbo.test','U') is not null drop table dbo.test

create table test
( id int identity not null,dummy int not null )
go

SET IDENTITY_INSERT dbo.test ON

insert into test(id,dummy) values(2147483647,1)

SET IDENTITY_INSERT dbo.test OFF

insert into test(dummy) values(1)

错误:

(1 row(s) affected)
Msg 8115,Level 16,State 1,Line 8
Arithmetic overflow error converting IDENTITY to data type int.
Arithmetic overflow occurred.

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读