I am running a SQLite database in memory and I am attempting to drop a table with the following command.
DROP TABLE 'testing' ;
But when I execute the SQL statement, I get this error
SQL logic error or missing database
Before I run the “Drop Table” query I check to make sure that the table exists in the database with this query. So I am pretty sure that the table exists and I have a connection to the database.
SELECT count(*) FROM sqlite_master WHERE type='table' and name='testing';
This database is loaded in to memory from a file database and after I attempt to drop this table the database is saved from memory to the file system. I can then use a third party SQLite utility to view the SQLite file and check to see if the “testing” exists, it does. Using the same 3rd party SQLite utility I am able to run the “Drop TABLE” SQL statement with out error.
I am able to create/update tables without any problems.
My questions:
- Is there a difference between a memory database and a file database in SQLite when dropping a table?
- Is there a way to disable the ability to drop a table in SQLite that I may have accentually turned on somehow?
Edit: It appears to have something to do with a locked table. Still investigating.
I had the same problem when using Sqlite with the xerial jbdc driver in the version 3.7.2. and JRE7
I first listed all the tables with the select command as follows:
And then tried to delete a table like this:
I was working on a database stored on the file system and so it seems not to effect the outcome.
I used the
IF EXISTScommand to avoid listing all the table from the master table first, but I needed the complete table list anyway.For me the solution was simply to change the order of the
SELECTandDROP.