SQLite - Drop a Database

To drop a database in SQLite, delete it from the file system.

SQLite does not use the DROP DATABASE statement like many other database management systems do.

It doesn't use the CREATE DATABASE statement either.

SQLite stores its databases as a normal file within the computer's file system, so creating and dropping databases is not really applicable.

If you need to completely remove a database, you will need to delete the database file from the file system.

If you don't know the name and/or path of the database file, use the .databases command:


sqlite> .databases

seq  name             file                                                      

---  ---------------  ----------------------------------------------------------

0    main             /Users/quackit/sqlite/music.db                            

2    Movies           /Users/quackit/sqlite/movies.db    

Then you can navigate to the file in the file system and delete it.

Detach a Database

You can also detach a database from the current connection. Doing this won't delete the actual database file — it just removes it from your connection.

You can detach a database using its alias, like this:

After running that code, use the .databases command to review the list of databases to see it removed:


sqlite> .databases

seq  name             file                                                      

---  ---------------  ----------------------------------------------------------

0    main             /Users/quackit/sqlite/music.db