473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Will "Random AutoNumber" reuse deleted values?

yf
A KB article
"http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells
that the maximum number of records that a table may hold if the PRIMARY
key data type is set to AUTONUMBER is 4,294,967,295.

Suppose the PRIMARY key data type is set to "RANDOM" AutoNumber.

Suppose an application
(a) successfully INSERTS "X" records, then
(b) successfully DELETES "Y" records (X >= Y), then
(c) successfully INSERTS "Z" records to a table to the capacity limit
of that primary key (i.e. insertion of a "Z+1"th record would have
caused a "duplicate primary key" condition).

Suppose there are no hardware or software failures and unlimited
HDD/RAM space.

Is it guaranteed that (X-Y+Z) = 4,294,967,295 ?
I.e. will Random AutoNumber reuse all "holes" left after deletion of Y
records?

--

Nov 13 '05 #1
4 5122
It's random: there's no guarantee that an attempt won't be made to reuse any
number.

Since there's a 2 GB limit on an MDB, I rather suspect you'll hit that limit
long before you use up all of the autonumber values.

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

"yf" <yf******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
A KB article
"http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells
that the maximum number of records that a table may hold if the PRIMARY
key data type is set to AUTONUMBER is 4,294,967,295.

Suppose the PRIMARY key data type is set to "RANDOM" AutoNumber.

Suppose an application
(a) successfully INSERTS "X" records, then
(b) successfully DELETES "Y" records (X >= Y), then
(c) successfully INSERTS "Z" records to a table to the capacity limit
of that primary key (i.e. insertion of a "Z+1"th record would have
caused a "duplicate primary key" condition).

Suppose there are no hardware or software failures and unlimited
HDD/RAM space.

Is it guaranteed that (X-Y+Z) = 4,294,967,295 ?
I.e. will Random AutoNumber reuse all "holes" left after deletion of Y
records?

--

Nov 13 '05 #2
yf
Too bad... the other scenario I had in mind was:
{add 10,000,000 records, delete 9,000,000 records} repeated daily.
Looks like after 429 days I'll exsaust all 4,294,967,295 Random
AutoNumber unique values and will start occasionally (with a
probability 10%) getting a "duplicate primary key"?

Nov 13 '05 #3
yf wrote:
Too bad... the other scenario I had in mind was:
{add 10,000,000 records, delete 9,000,000 records} repeated daily.
Looks like after 429 days I'll exsaust all 4,294,967,295 Random
AutoNumber unique values and will start occasionally (with a
probability 10%) getting a "duplicate primary key"?


It would need compactinmg every day then :-)

BTW for adding 1,000,000 records a day, are you sure you want to use
something as lightweight as Access/Jet?

--
This sig left intentionally blank
Nov 13 '05 #4
Once a record is deleted, its Autonumber value can be reused. Even with a
standard incremental Autonumber, a value can be reused if the highest-numbered
value is deleted, then the database is compacted. For this reason, no kind of
Autonumber is suitable for use as a logical key.

If, however, the Autonumber value will only be used as a surrogate key within
the database app and will never be used as an external refrence, and if the
database makes good use of enforced referential integrity rules, there should
be no consequences to possible reuse of previously deleted Autonumber values.

So - you may frequently want to use Autonumer keys as surrogate keys, but use
another technique other than autonumber to generate unique logical keys. A
good logical key might be a string representation of a new GUID obtained using
a Windows API call. Another option I rather like for building unique logical
keys is CCur(Format(Now,"yyyymmdd") & Format(Timer*10,"000000.00") &
Format(Rnd*100,"00")), making sure to call Randomize at some point prior to
executing this code. If, for some reason, you'd like make sure records will
sort randomly using the logical key, change that formula to
CCur(Format(Rnd*100,"00") & Format(Timer*1000,"00000000") &
Format(Now,"ddmm.yyyy")).

If you need more assurance that the random number part won't be duplicated
during the same millisecond, you can replace the call to Rnd with a call to a
custom non-repeating hash procedure and seed its initial counter with a random
value using Rnd. An easy hash (though not very random if that matters) is to
count from 1 and XOR the counter value with the random seed. To be fancier,
you could use modulus multiplication or exponentiation, though that can be
tricky in VB/VBA.

On 6 Dec 2004 13:16:43 -0800, "yf" <yf******@gmail.com> wrote:
A KB article
"http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells
that the maximum number of records that a table may hold if the PRIMARY
key data type is set to AUTONUMBER is 4,294,967,295.

Suppose the PRIMARY key data type is set to "RANDOM" AutoNumber.

Suppose an application
(a) successfully INSERTS "X" records, then
(b) successfully DELETES "Y" records (X >= Y), then
(c) successfully INSERTS "Z" records to a table to the capacity limit
of that primary key (i.e. insertion of a "Z+1"th record would have
caused a "duplicate primary key" condition).

Suppose there are no hardware or software failures and unlimited
HDD/RAM space.

Is it guaranteed that (X-Y+Z) = 4,294,967,295 ?
I.e. will Random AutoNumber reuse all "holes" left after deletion of Y
records?


Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: bhennon | last post by:
Hey all, I have a small php script that calls a random image at the following page. http://www.2006ymcanationals.com/random.php IT WORKS IF I go directly to the above link. I am trying to...
4
by: Jesse Noller | last post by:
Hello - I'm probably missing something here, but I have a problem where I am populating a list of lists like this: list1 = list2 = list3 = main_list =
6
by: Tom | last post by:
Is there a way to not display "Autonumber" in the primary key testbox when the PK is an autonumber in a new record? Tom
1
by: BT Openworld | last post by:
I've just had to upgrade to Access 2003. Our company's main sales database started in Access V1.0 and has progressed through V2.0 and 97 without problems. I've converted it to 2003 format and have...
2
by: plawrow | last post by:
Hi, I am trying to assign "autonumber" for each line related to given record. TRANSACTION# DATE AMOUNT 3 01/01/05 100 3 01/01/05 150 3 ...
21
by: MLH | last post by:
I have an A97 database table (tblCorrespondence] in a database installed at 2 sites. The table's key field is not a natural key - its an autonumber field. Here are the values at the 2 sites....
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.