1

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.

2 Answers 2

2

You should not have quotes in your DROP TABLE command. Use this instead:

DROP TABLE testing
Sign up to request clarification or add additional context in comments.

1 Comment

Oops, there are not quotes in the real version. I added them to the question to make things clear but I guess it just made things more complicated. Edited the question and removed the quotes.
1

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:

SELECT name FROM sqlite_master WHERE type='table'

And then tried to delete a table like this:

DROP TABLE IF EXISTS TableName

I was working on a database stored on the file system and so it seems not to effect the outcome. I used the IF EXISTS command 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 SELECT and DROP.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.