重新启动自动编号 [英] Restart Autonumber

查看:91
本文介绍了重新启动自动编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个带有自动编号主键和100条记录的表,并且我删除了最后50条记录的

,则添加的下一条记录的主键为101.是

在最后50条记录被删除后,有没有办法让主键从51开始?


谢谢!


Traci

If I have a table with an autonumber primary key and 100 records and I delete
the last 50 records, the next record added would have a primary key of 101. Is
there any way to have the primary key start at 51 after the last 50 records are
deleted?

Thanks!

Traci

推荐答案

这就是自动编号的方式。事实上,你很幸运,数字

目前对应于记录号码:如果你开始添加记录

然后决定不保存它,你会失去那个数字。另外,如果您要使用Access Replication,请注意自动编号值

将不再是连续的,而是随机的。


自动编号字段实际上不是用于人类消费:它们唯一的意图是提供(实际保证的)唯一值,可以是

用作主键,他们填充或没有间隙的目的。


如果在读完所有这些之后,你仍然想尝试使用自动编号和

有它们的值意味着什么,你可以在执行

删除后压缩数据库,并且分配的下一个自动编号应该比最后一个使用的

多一个。 br />

-

Doug Steele,Microsoft Access MVP
http://I.Am/DougSteele

(请不要发电子邮件!)


" ;崔西" < TM ****** @ earthlink.net>在消息中写道

新闻:BW ***************** @ newsread2.news.atl.earthl ink.net ...
That''s the way autonumbers are. In fact, you''re lucky that the numbers
currently correspond to the record number: had you started to add a record
and then decided not to save it, you would have lost that number. Also, if
you were to use Access Replication, be aware that the autonumber values
would no longer be sequential, but random.

Autonumber fields really aren''t intended for "human consumption": their only
intent is to provide a (practically guaranteed) unique value that can be
used as a primary key, and they fill that purpose with or without gaps.

If, after reading all this, you still want to try and use autonumbers and
have their value mean something, you can compact the database after doing
the delete, and the next autonumber assigned should be one more than the
last one used.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Traci" <tm******@earthlink.net> wrote in message
news:BW*****************@newsread2.news.atl.earthl ink.net...
如果我有一个带有自动编号主键和100条记录的表,而我
删除最后50条记录,则添加的下一条记录的主键为
101.有没有办法让在最后50个
记录被删除后,主键从51开始?

谢谢!

Traci
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key start at 51 after the last 50 records are deleted?

Thanks!

Traci



只是紧凑的数据库,下一个数字将是51

Slawomir Piascik


" Traci" < TM ****** @ earthlink.net>在消息中写道

新闻:BW ***************** @ newsread2.news.atl.earthl ink.net ...
Just compact database, next number will be 51

Slawomir Piascik

"Traci" <tm******@earthlink.net> wrote in message
news:BW*****************@newsread2.news.atl.earthl ink.net...
如果我有一个带有自动编号主键和100条记录的表,而我
删除最后50条记录,则添加的下一条记录的主键为
101.有没有办法让在最后50个
记录被删除后,主键从51开始?

谢谢!

Traci
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key start at 51 after the last 50 records are deleted?

Thanks!

Traci



实际上,这不会恢复自动编号。它将从删除之前的最后一个自动编号中取出




-

Reggie


----------

" Sal" < SL ***** @ bellatlantic.net>在消息中写道

新闻:Nu ***************** @nwrdny01.gnilink.net ...
Actually, This will not recover the autonumbers. It will pick up right from
the last autonumber before the delete.

--
Reggie

----------
"Sal" <sl*****@bellatlantic.net> wrote in message
news:Nu*****************@nwrdny01.gnilink.net...
只是紧凑数据库,下一个数字将是51

Slawomir Piascik

Traci < TM ****** @ earthlink.net>在消息中写道
新闻:BW ***************** @ newsread2.news.atl.earthl ink.net ...
Just compact database, next number will be 51

Slawomir Piascik

"Traci" <tm******@earthlink.net> wrote in message
news:BW*****************@newsread2.news.atl.earthl ink.net...
如果我有一个带有自动编号主键和100条记录的表,我
If I have a table with an autonumber primary key and 100 records and I


删除

最后50条记录,添加的下一条记录将有一个主键
the last 50 records, the next record added would have a primary key of


101.


101. Is

在最后50个


记录

删除后,有没有办法让主键从51开始?

谢谢!

Traci
deleted?

Thanks!

Traci




这篇关于重新启动自动编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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