What happen in SQL 2005 when it run out of number for an autonumber column?

后端 未结 6 605
囚心锁ツ
囚心锁ツ 2021-02-08 12:07

What happen when SQL Server 2005 happen to reach the maximum for an IDENTITY column? Does it start from the beginning and start refilling the gap?

What is the behavior

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-08 13:08

    If the identity column is an Integer, then your max is 2,147,483,647. You will get an overflow error if you exceed it.

    If you think this is a risk, just use the BIGINT datatype, which gives you up to 9,223,372,036,854,775,807. Can't imagine a database table with that many rows.

    Further discussion here. (Same link as xsl mentioned).

提交回复
热议问题