在 MS Access 中擦除表格后如何从 1 重新开始计数? [英] How to restart counting from 1 after erasing table in MS Access?
问题描述
我在 MS Access 中有一个表,它在 ID
I have table in MS Access that has an AutoNumber
type in field ID
插入一些行后,ID
变成了200
然后,我已经删除了表中的记录.但是,当我尝试插入新行时,我看到 ID
以 201
Then, I have deleted the records in the table. However, when I tried to insert a new row, I see that the ID
starts with 201
如何强制 ID
以 1
重新启动,而不必删除表并创建新表?
How can I force the ID
to restart with 1
, without having to drop the table and make new a new one?
推荐答案
您可以使用:
CurrentDb.Execute "ALTER TABLE yourTable ALTER COLUMN myID COUNTER(1,1)"
我希望你没有使用这个表的关系,我希望它是空的,我希望你明白你能(大部分)依赖一个自动编号是唯一的.根据情况,您可以得到间隙、跳跃、非常大甚至负数.如果您的自动编号意味着什么,那么您就有一个大问题等着发生.
I hope you have no relationships that use this table, I hope it is empty, and I hope you understand that all you can (mostly) rely on an autonumber to be is unique. You can get gaps, jumps, very large or even negative numbers, depending on the circumstances. If your autonumber means something, you have a major problem waiting to happen.
这篇关于在 MS Access 中擦除表格后如何从 1 重新开始计数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!