SQL Server adds attributes (auto-increment) to tables that have been created

Source: Internet
Author: User


When you create this table, set the ID to type int, and then set the identity to Yes and the seed to 1 increments.
If this table is already built, you can add a field called ID at the end, and then do the same as above, then save to add. (Be sure to set it up after saving)

ALTER TABLE student Add ID int identity (up to)

After saving a new column ID, in the table design to delete the primary key, the ID moved to the first column location, the ID is set as the main key.

Note: The identity is best used when all the data is created and last added, otherwise the serial number is not changed and memory is consumed.

SQL Server adds attributes (auto-increment) to tables that have been created

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.