Reputation: 13
I know how to delete a comment by position, but how do you delete all comments from a datasource?
I want to delete it when a button is clicked.
Upvotes: 0
Views: 176
Reputation: 39698
To delete all of the data in a table, you need to do something like this:
DELETE FROM table_name
Upvotes: 2
Reputation: 116167
Correct answer is
DELETE FROM mytable
Do NOT use *
after DELETE - it will cause syntax error!
Using TRUNCATE mytable
would have been tempting, but unfortunately SQLite does NOT support TRUNCATE
.
However, SQLite does provide special optimization provision for DELETE FROM
statement. Namely, if WHERE
clause was not specified (like in our case), then all space taken by rows in table is reclaimed very quickly, so behaviour is similar to true TRUNCATE
.
Upvotes: 1