Hi, I have a java program that creates a sqlite database for me. When I finish the program, I want the database to be deleted so that there is no record of it on the computer. I have the following code:
public void borrarSQLite() {
try {
con.getS().executeUpdate("DROP DATABASE peval2");
System.out.println("BD SQLite eliminada correctamente");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println("ERROR AL ELIMINAR LA BD SQLite");
}
}
I have tried to execute the query directly in SQLite and it tells me the following:
near "DATABASE": syntax error: drop DATABASE
How do I drop an SQLite database?
People used to working with other databases are used to having a
DROP DATABASE
, but in SQLite there is no similar command.The reason? In SQLite there is no "database server": SQLite is an embedded database, and its entire database is contained in one file. So there is no need for a SQLite "drop database" command, all you need to do to drop the database is delete the SQLite database file you were accessing