Delete All Data with SQLite delete syntax?
If you have a standard primary id column (and you should) you can do
DELETE FROM tablename WHERE id > -1;
And this will delete all rows in the table since there is no id less than 0.
DELETE FROM tablename
did not work for me. I was using a sqlite3 database on iPhone, which I assume the poster was, as well. For me to get this to work, I needed to:
DROP table tablename
followed by a CREATE
statement, if I wanted the table to still exist (without any rows).
Of course, that requires knowing the right CREATE
statement. Using the SQLManager plugin for Firefox quickly reverse-engineered for me the correct CREATE
statement to use. I never figured out why DELETE FROM tablename
didn't work, but it definitely didn't, in my case.