How to restart counting from 1 after erasing table in MS Access?

前端 未结 6 2115
栀梦
栀梦 2020-11-27 04:39

I have table in MS Access that has an AutoNumber type in field ID

After inserting some rows, the ID has become 200

6条回答
  •  不知归路
    2020-11-27 05:16

    In addition to all the concerns expressed about why you give a rat's ass what the ID value is (all are correct that you shouldn't), let me add this to the mix:

    If you've deleted all the records from the table, compacting the database will reset the seed value back to its original value.

    For a table where there are still records, and you've inserted a value into the Autonumber field that is lower than the highest value, you have to use @Remou's method to reset the seed value. This also applies if you want to reset to the Max+1 in a table where records have been deleted, e.g., 300 records, last ID of 300, delete 201-300, compact won't reset the counter (you have to use @Remou's method -- this was not the case in earlier versions of Jet, and, indeed, in early versions of Jet 4, the first Jet version that allowed manipulating the seed value programatically).

提交回复
热议问题