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?
Asked
Active
Viewed 1.4k times
1
-
4SQLite databases are just files. You can delete the database by deleting the file. Reference: http://www.sqlite.org/about.html – mechanical_meat Jan 17 '14 at 07:17
-
Where will the files be present in ubuntu? – dmn Jan 17 '14 at 07:22
-
Delete the file. Where is the file? where the programme using it place it. – bgusach Jan 17 '14 at 07:38
3 Answers
2
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
Trausti Thor
- 3,604
- 30
- 41
0
Pasting a stackoverflow link for your reference. This may be useful how to drop database in sqlite?
Community
- 1
- 1
Supraja Suresh
- 49
- 8
0
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.
King Leo RC
- 1
- 2