your image

SQLite - Drop a Database

quackit
Related Topic
:- SQLite Databases

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> .databasesseq  name             file---  ---------------  ----------------------------------------------------------0    main             /Users/quackit/sqlite/music.db2    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:

 

DETACH DATABASE Movies;

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

sqlite> .databasesseq  name             file---  ---------------  ----------------------------------------------------------0    main             /Users/quackit/sqlite/music.db    

Comments