Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SQL auto-increment reset

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

SQL auto-increment reset

There are three main ways to collect information from the Internet and reset the self-increasing logo column in SQL:

Method 1: delete the original table data and reset the self-incrementing column

-delete the original table data and reset the auto-increment column truncate table tablename-the truncate mode can also reset the auto-increment field

Method 2: retain the data reset table self-incrementing column

-- reserved data reset table self-incrementing column DBCC CHECKIDENT (tablename,reseed,0)

Method 3: allow the insert self-increment column to be displayed

-- setting to allow explicit insertion of self-incrementing column SET IDENTITY_INSERT tablename ON-- data after adding, you need to turn off the display and insert SET IDENTITY_INSERT tablename Off.

When the setting allows the insert self-increment column to be displayed, you need to specify the self-increment column value yourself, otherwise an error will be reported.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report