Skip to content

How to delete all rows of all tables from database, or otherwise clear a database entirely? #3027

Answered by simolus3
triallax asked this question in Q&A
Discussion options

You must be logged in to vote

So the easiest way is to just close the database instance and then delete the database File that you're passing to NativeDatabase.

If it's easier to keep the database open, you can delete content from all tables like this:

await transaction(() async {
  for (final table in allTables) {
    await delete(table).go();
  }
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@triallax
Comment options

Answer selected by triallax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants