自动增量标识列

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

使用Visual C#2008 Express和SQL Server 2008 Express,我想将新记录插入数据库AdventureWorks,表格Person.Contact。 到我的令人惊讶的是,这个表的'int-value identity列" ContactID"似乎不是自动增量。我不知道如何确认这是如此。 (我已经安装了SQL Server Management Studio,如果有帮助的话。) 如何确认这一点,以及如何使ContactID自动增加? 顺便提一下,自动递增会从最高的现有ContactID开始递增,还是会先使用表中不存在的较小的ContactID值(可能是由于删除)?

Using Visual C# 2008 Express and SQL Server 2008 Express, I would like to insert new records into database "AdventureWorks", table "Person.Contact". To my surprise, this table''s int-value identity column "ContactID" does not appear to be auto-increment. I don''t know how to confirm for sure that this is so. (I have installed SQL Server Management Studio, if that helps.) How can I confirm this, and how can I make ContactID auto-increment? And incidentally, will auto-increment just start incrementing from the highest existing ContactID, or will it first use lesser ContactID values that are absent from the table (presumably due to deletions)?

推荐答案

打开Management Studio。右键单击表格,然后选择修改。在身份规范上,检查属性是否设置为YES。 - CK Open the Management Studio. Right click on the table then choose modify. On the Identity Specification, check if the property is set to YES. -- CK

ck9663: 在SQL Server 2008 Management Studio Express中,只有三个选项出现在身份规范下(身份),身份增量和身份种子,分别设置为是,1和1。身份增量= 1似乎意味着自动增量已开启,但它似乎无法正常工作。 但也许我只是不知道我是什么我在做。我按如下方式创建新的DataRow: ck9663: In SQL Server 2008 Management Studio Express, only three options appear under Identity Specification: (Is Identity), Identity Increment and Identity Seed, which are set to Yes, 1 and 1, respectively. Identity Increment = 1 would seem to imply that auto-increment is on, but it doesn''t seem to be working. But maybe I just don''t know what I''m doing. I create the new DataRow as follows: 展开 | 选择 | Wrap | 行号

尝试对表本身进行插入。或许它是一个示例数据库,所以微软只允许只读。 - CK Try to do an insert on the table itself. Or maybe that it''s a sample DB so microsoft only allow read-only. -- CK

更多推荐

自动增量标识列

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

发布评论

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

>www.elefans.com

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