使用自动增量设置列的起始值

编程入门 行业动态 更新时间:2024-10-12 20:27:33
本文介绍了使用自动增量设置列的起始值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个表 Orders 包含以下字段:

身份证 |小计 |税|航运 |创建日期

Id 列设置为 autoincrement(1,1).

这将用于电子商务店面.有时,当前的电子商务商店迁移到我的平台并且他们已经有订单 - 这可能意味着他们当前的 Order.Id 是,例如,9586.>

我想让 autoincrement 字段从那个值开始.

我该怎么做?

解决方案

来自 重置 SQL Server 标识列:

检索表 Employees 的标识:

DBCC checkident ('Employees')

修复身份种子(如果由于某种原因数据库正在插入重复的身份):

DBCC checkident ('Employees', reseed)

将表 Employees 的身份种子更改为 1000:

DBCC checkident ('Employees', reseed, 1000)

插入的下一行将从 1001 开始.

I have a table Orders with the following fields:

Id | SubTotal | Tax | Shipping | DateCreated

The Id column is set to autoincrement(1,1).

This is to be used in an E-commerce storefront. Sometimes a current E-commerce store is migrated to my platform and they already have orders - which could mean that their current Order.Id is, for example, 9586.

I want to have the autoincrement field start from that value.

How can I do this?

解决方案

From Resetting SQL Server Identity Columns:

Retrieving the identity for the table Employees:

DBCC checkident ('Employees')

Repairing the identity seed (if for some reason the database is inserting duplicate identities):

DBCC checkident ('Employees', reseed)

Changing the identity seed for the table Employees to 1000:

DBCC checkident ('Employees', reseed, 1000)

The next row inserted will begin at 1001.

更多推荐

使用自动增量设置列的起始值

本文发布于:2023-07-15 13:08:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1111401.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:增量

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!