What is the maximum ID for the ID increment column in SQL Server?

Source: Internet
Author: User

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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.