How to reset identity column in MS Access

前端 未结 3 666
醉梦人生
醉梦人生 2021-01-13 23:46

I have a windows application connected with MS Access 2007 database

It had more than 300 records in Customer Table.

I have deleted

相关标签:
3条回答
  • 2021-01-14 00:22

    If you really must reset the autonumber, and you should first consider @Eugene Rieck's answer, you can compact and repair the database, which is something you should be doing with a back-end database on a fairly regular basis, anyway.

    0 讨论(0)
  • 2021-01-14 00:25

    On the operational side, you can drop an readd the column.

    On the strategic side, I think you should rethink the problem: If the value of an identity column, apart from being unique, matters to you, you might be heading in a dangerous direction: You should think of such a column as being completly without content, apart from being a way to uniquely address a row.

    0 讨论(0)
  • 2021-01-14 00:30

    See here. The key is:

    strSql = "ALTER TABLE [" & strTable & "] ALTER COLUMN [" & strAutoNum & "] COUNTER(" & lngNext & ", 1);"
    

    Alternatively, just drop and recreate the table.

    0 讨论(0)
提交回复
热议问题