'Deleting SQLite database : How to?
There is this particular database named temp which I want to delete which was created using SQLite on ubuntu machine. How do I delete this databse?
Solution 1:[1]
The case is quite simple.
Either delete the file like this :
rm -fr filename
Or in terminal type something like :
$ sqlite3 tempfile (where tempfile is the name of the file)
sqlite> SELECT * FROM sqlite_master WHERE type='table';
You will see a list of tables like this as an example:
table|friends|friends|2|CREATE TABLE friends (id int)
then just type
sqlite> drop table friends (or the name you want to drop)
Then press ctrl-d to exit.
It is that simple
Solution 2:[2]
Pasting a stackoverflow link for your reference. This may be useful how to drop database in sqlite?
Solution 3:[3]
SQLite saves data to a file. Leverage the methods tailored to the specific OS so you can delete the file. I.E. with Android use the System.IO.File.Delete() method.
Here is some code showing what I used to create and delete my SQLite database on an android device in C#:
public class SQLite_DB
{
private string databasePath;
public SQLiteAsyncConnection GetConnection()
{
databasePath = Path.Combine(FileSystem.AppDataDirectory, "sqlite_db.db3");
SQLiteAsyncConnection database = new SQLiteAsyncConnection(databasePath);
return database;
}
public bool DeleteDatabase()
{
File.Delete(databasePath);
if (File.Exists(databasePath))
return false;
return true;
}
}
For Ubuntu, a simple rm -rf [database path/filename] should suffice.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Trausti Thor |
| Solution 2 | Community |
| Solution 3 |
