自动生成不正常的顺序 [英] auto generate no not in proper order

查看:69
本文介绍了自动生成不正常的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vb.net 2010 ms访问数据库中做了一个新项目当记录获取保存序列时没有自动生成当我删除记录序列号没有正确的顺序请给解决方案自动生成没有

解决方案

IDENTITY值不回收:所以如果你有

 1 Joe 
2 Mike
3 Mary



您删除Mike然后当您添加Alice时,数字2将不会被重复使用 - 您将获得

< pre lang =text> 1 Joe
3 Mary
4 Alice



这是故意的,无论是速度还是确保非正式外键关系不会导致Mike的信息在创建时添加到Alice的帐户中。



如果您总是想要序列号,那么您需要使用ROW_NUMBER()而不是身份字段 - 但请注意,您需要一个合适的字段来进行ORDER BY,或者每次都可能有不同的数字。


I am doing a new project in vb.net 2010 ms access database when record get save the serial no auto generate when i delete record the serial no not in proper order please give solution auto generate no

解决方案

IDENTITY values do not recycle: so if you have

1 Joe
2 Mike
3 Mary


And you delete "Mike" then when you add "Alice" the number "2" will not be reused - you will get

1 Joe
3 Mary
4 Alice


This is intentional, both for speed and to ensure that "informal" foreign key relationships do not result in Mike's information being added to Alice's account when she is created.

If you always want sequential numbers, then you need to use ROW_NUMBER() instead of the identity field - but be aware that you will need a suitable field to to ORDER BY or the number may well be different each time.


这篇关于自动生成不正常的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆