What is a self-increment column
The ID column can be set to self-increment in SQL Server. That is, you do not need to specify a value for the ID, the column is automatically assigned a value by SQL Server, and the value of each new column ID is added one, with an initial value of 1.
It is important to note that even if all the previously added data is deleted, then the data is added. The ID of the record will still not start at 1, but the original maximum value plus 1.
Range of values for self-increment columns
Typically, when you define an auto-increment column, you specify that its data type is of type int. Also, only columns of type int and its related data types can be specified as self-increment columns.
Here are the data types that the self-increment column can use:
bigint -2^ the(-9,223,372,036,854,775,808) to2^ the-1(9,223,372,036,854,775,807)8bytesint -2^ to(-2,147,483,648) to2^ to-1(2,147,483,647)4bytessmallint -2^ the(- +,768) to2^ the-1( +,767)2bytestinyint 0To255
You can see that only the value of the int type can be as much as 2.1 billion, which is sufficient in a general application.
However, if you really insert hundreds of millions of of the data in a table, you might be less efficient. = = So it was proposed to use partitioned tables to solve such problems.
What is the maximum ID for the ID increment column in SQL Server?