Access中的自动编号是如何工作的? [英] How AutoNumber in Access works?

查看:306
本文介绍了Access中的自动编号是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解访问中所谓的自动编号"的工作方式吗?
从表中删除后,它将选择最简单的算法并浪费ID号.它的工作方式与我的想法不同.例如,如果我有第1、2、3、4行,那么在删除第2行之后,ID 3和4应该减少到2和3,并且我们有带有1、2、3的新行,但它返回的行是1 ,3、4.然后,如果我们在表格中添加新行,则会自动在ID列中添加5,这意味着数字2可能不再被使用,这很浪费.另外,即使我删除了4行,要添加的下一行ID也为5,而不是1(我以为肯定是1,但不是).
我的想法出了什么问题,或者似乎我们无法达到长整数的最大值?因此,我们应该使它那样工作.
非常感谢!

I can''t understand the way what called "Autonumber" in access works?
It chooses the easiest algorithm and WASTE the ID numbers after deleted from table. It works the way not like what I think. For example, if I have rows 1, 2, 3, 4. After deleting the row 2, the IDs 3 and 4 should be decreased to 2 and 3 and we have new rows with 1, 2, 3 but it returns rows with 1, 3, 4. Then if we add a new row to the table, it automatically add 5 to the ID column, that means the number 2 may not be used again, that''s a waste. Plus even when I delete 4 rows, the next row to be added has the 5 as its ID not 1 (I thought it is surely 1, but it isn''t).
What''s wrong with my thought or it seems that we can''t reach the max value of a Long Integer number? So we should make it work that way.
Thank you so much!

推荐答案

数字应该唯一地标识一行.并且通常也是主键.因此,没有重复使用的问题.或重新编号.两者都会破坏使用自动编号的目的.
The numbers are supposed to uniquely identify a row. And are usually primary keys too. So there''s no question of reuse. Or renumbering. Both of which would break the purpose of using autonumbering.


又一个解释强化了Nishants的观点:
引用这些行的其他表呢?如果要对自动编号列(PK)进行重新编号,则其他表中包含的所有引用都将中断.

最好的问候,

-MRB
One more explanation fortifying Nishants opinion:
What about other tables referencing these rows. If the autonumber columns (PK) were to be renumbered all references contained in other tables would break.

Best Regards,

-MRB


这篇关于Access中的自动编号是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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