Results 1 to 2 of 2

Thread: Mooooooooo!

  1. #1
    12OzCoffeeCup Guest

    Default Mooooooooo!

    So, instead of using the access DB primary key as a directory marker, how can i assign an automatic number to a record when it is put int the database and have it always strat at 1 and always stay constant so that if i delete #5 it won&#039t go "1,2,3,4,6,7,etc"?

  2. #2
    Join Date
    Dec 1969

    Default relative record numbers

    You can&#039t.<BR><BR>At least not with most DB engines. I think DB2 (certainly on some platforms) will let you do this, albeit only *after* you have run a query on the table.<BR><BR>But you need to understand that "record order" is truly a foreign concept to a DB engine. A *good* DB does *not* keep all the records neatly packed in some sort of sequence. Instead, it just grabs space from any good spot for the next record and, when a record is deleted, just marks that space as empty, so the next added record can go in there. So internal to a DB, the records are as scattered and fragmented as a hard drive gets after a year&#039s use. And the only way to "unscatter" is to copy the given table, in some order of the users choice, to a new table, drop the old one, and rename the new one. <BR><BR>One thing you could do: Create a "view" (or temporary table, if the DB you are using doesn&#039t support views), ordered as you desire it. Then you can get a recordcount on that view and do "move", etc., as needed.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts