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.