is there TRUNCATE in Access?

后端 未结 9 1472
滥情空心
滥情空心 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:46

    There's no truncate in MS Access as far as I know but you can resolve the auto-number issue remembering the last number after delete. There's a way in MS Access to start with 1 after deleting records with auto-number field. If you're using ms-access-2007 you can find the Compact and Repair Database feature by selecting Manage, located under the Office Button. You can also have your database compact and repair itself every time it is closed, by activating the Compact on Close option. If you would like to set this option, you can find it in the Access Options for the Current Database.

    enter image description here

    0 讨论(0)
  • 2021-01-04 03:48

    In MS_Access Database, "Truncate is not supported". So we can delete the all records first by "Delete" query.

    After delete the records, we can alter the "ID" column starts from 1 by using "Alter" query.

    Query:

      "Delete * from (Your Table Name); 
      Alter Table (Your Table Name) Alter Column (Your Column Id) Counter(1,1);"
    

    Using this two queries in single execution we can delete all records and reset the column id starts from 1.

    0 讨论(0)
  • 2021-01-04 03:51

    I also the same problem before, what I did was I go back to the table in modify mode. Then I deleted the field name with autonumber and I inserted again with the same name. The result of the autonumber when I run in view mode was back to the number 1 the first Entry.

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