Auto-increment column zeroing Method

Source: Internet
Author: User
Recently, I was working on a project with a lot of test data in the database. Later I deleted all the test data using the delete * Statement. However, I found that the base of the Self-increasing column (usually the primary key) was not zero, after reading the information, I found a solution, that is, using the TRUNCATE function, you can delete all the data in the table and set the base of the auto-growth column to zero. The SQL statement is as follows: views

Recently, I was working on a project with a lot of test data in the database. Later I deleted all the test data using the delete * Statement. However, I found that the base of the Self-increasing column (usually the primary key) was not zero, after reading the information, I found a solution, that is, using the TRUNCATE function, you can delete all the data in the table and set the base of the auto-growth column to zero. The SQL statement is as follows: view s

Recently, I was working on a project with a lot of test data in the database. Later I deleted all the test data using the delete * Statement. However, I found that the base of the Self-increasing column (usually the primary key) was not zero, after reading the information, I found a solution, that is, using the TRUNCATE function, you can delete all the data in the table and set the base of the auto-growth column to zero. The SQL statement is as follows:

View sourceprint? 1 truncate table tableName -- data to be operated in tableName

Note that all the data in the table is deleted before the preceding SQL statement takes effect. I need to delete the data. If the data cannot be cleared, there is no way to delete the data. So sometimes I feel that it is not very practical.

Note: More exciting articles, please pay attention to SanlianProgramming TutorialTopic.

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.