is there TRUNCATE in Access?

后端 未结 9 1473
滥情空心
滥情空心 2021-01-04 03:19

I have a table in an Access database with an autonumber field.

When I delete all the records from the table, the autonumber remembers the last number.

Does A

9条回答
  •  被撕碎了的回忆
    2021-01-04 03:39

    There is another way that doesn't require altering the table or compacting and repairing. It will work better for you if you have a distributed database. As of 2000, Access will accept an insert value into an autonumber field and start incrementing there. Do it in a query or in code like this.

    CurrentProject.Connection.Execute "DELETE FROM Mytbl"
    CurrentProject.Connection.Execute "INSERT INTO Mytbl(ID) VALUES(0)"
    CurrentProject.Connection.Execute "DELETE FROM Mytbl"
    

    Note: Put adExecuteNoRecords after the execute command for better performance. e.g. CurrentProject.Connection.Execute sql, , adExecuteNoRecords

提交回复
热议问题