9

I want a debug function to do this, but I'm unaware of whether one already exists. Going through and using 'drop table' for each of my tables will be a pain.

Help appreciated.

Hamster
  • 557
  • 2
  • 7
  • 12

2 Answers2

7

Since the database is just one file, you can indeed just erase it. If you want something more automatic, you can use the following to do it all programmatically:

  1. Recover your schema:

    SELECT group_concat(sql,';') FROM sqlite_master;

  2. Disconnect from the database

  3. Delete the database file

  4. Create your schema again with what was returned from the above query

If you used any particular options for your original database (page_size, etc), they will have to be declared manually as well.

MPelletier
  • 16,256
  • 15
  • 86
  • 137
3

to "drop database" for sqlite, simply delete the database file (and recreate if needed)

second
  • 28,029
  • 7
  • 75
  • 76
  • The version of sqlite I have to work with doesn't appear to have this command. – Hamster Aug 30 '10 at 12:17
  • 5
    which command? you don't do "drop database" (doesn't exist). instead, delete the db file from your hard drive. – second Aug 30 '10 at 12:20