Reset tables to delete all data (1 Viewer)

jillrein

Registered User.
Local time
Today, 08:39
Joined
Apr 19, 2008
Messages
28
Can someone help please. I have built and tested my database and now need to delete all the data and reset all autonumbers. Is there an quick way to do this without having to create and run lots of delete queries?
 

boblarson

Smeghead
Local time
Today, 08:39
Joined
Jan 12, 2001
Messages
32,059
Can someone help please. I have built and tested my database and now need to delete all the data and reset all autonumbers. Is there an quick way to do this without having to create and run lots of delete queries?

You can open your tables and do EDIT > SELECT ALL and then hit your delete key.

As for resetting your autonumbers, once the table is empty and you run a COMPACT and REPAIR on the database it should reset them.

However, hopefully you aren't using autonumbers for anything that the user sees. It should only matter to the system what they are and it can manage it just fine. Autonumbers are used to give you a UNIQUE number but they are never guaranteed to always be in sequential order and once a record is started or deleted that autonumber is gone.
 

jillrein

Registered User.
Local time
Today, 08:39
Joined
Apr 19, 2008
Messages
28
Thanks for your help - I was rather hoping there was a simple way of creating a whole new set of blank tables - gets annoying having to delete from tables in the correct order to avoid problems with referential integrity rules but this certainly helps.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:39
Joined
Feb 28, 2001
Messages
27,150
jillrein, if you don't mis-use the keys/autonumber fields, you would never have any problem with RI anyway.
 

boblarson

Smeghead
Local time
Today, 08:39
Joined
Jan 12, 2001
Messages
32,059
Thanks for your help - I was rather hoping there was a simple way of creating a whole new set of blank tables - gets annoying having to delete from tables in the correct order to avoid problems with referential integrity rules but this certainly helps.

Your situation made me wonder if I could create a tool to help. So I did. This should reset all non-linked tables in your database. If you don't want one to be reset you can delete the table from the list of tables to reset. Also, you can set the deletion order if you wish by setting the order in the order field. If you do, make sure to replace all ZERO entries with something as they will fire first.
 

Attachments

  • DatabaseReset.zip
    80.7 KB · Views: 994
Last edited:

Simon_MT

Registered User.
Local time
Today, 16:39
Joined
Feb 26, 2007
Messages
2,177
What about creating a new database and importing tables - structure only. This seems a one-off task and this would do.

Alternatively, you could avoid Autonumbers altogether and use DMax("Field") + 1. I'm not sure this would be considered wise though!

Simon
 

jillrein

Registered User.
Local time
Today, 08:39
Joined
Apr 19, 2008
Messages
28
This is a great tool - thank you. I am thinking, if I store the delete order in a table in each database, I can then run this to reset everything without having to think about the order more than once! (as long as I exclude the delete order table from the list). I really appreciate your help.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 16:39
Joined
Sep 12, 2006
Messages
15,642
i do that

have a delete table to specifiy the delete order

then its just "delete * from " & whatevertable

-------
however - its one thing clearing out data in a test environment, or while you are developing, but you shouldnt need to do it regularly


--------
bob - did you mean non-linked tables, or linked tables?

not that it matters - same principle anyway
 

boblarson

Smeghead
Local time
Today, 08:39
Joined
Jan 12, 2001
Messages
32,059
bob - did you mean non-linked tables, or linked tables?

not that it matters - same principle anyway
The tool does NON-linked tables (so if it is linked to Access tables then it needs to be done on the backend). If you have SQL Server (or other ODBC linked tables) it doesn't do those.
 

cristiscu

New member
Local time
Today, 08:39
Joined
Jan 7, 2020
Messages
1
A very cheap alternative would be to simply use a fiverr gig:

fiverr.com/cristiscutaru/create-an-empty-copy-of-your-access-or-sqlite-database-file

I tried the tool recommended before and the idea was great, but it didn't work for my db.
 

Users who are viewing this thread

Top Bottom