Small. Fast. Reliable.
Choose any three.

SQL As Understood By SQLite

DELETE

sql-statement ::=DELETE FROM [database-name .] table-name [WHERE expr]

The DELETE command is used to remove records from a table. The command consists of the "DELETE FROM" keywords followed by the name of the table from which records are to be removed.

Without a WHERE clause, all rows of the table are removed. If a WHERE clause is supplied, then only those rows that match the expression are removed.

When the WHERE clause is omitted from a DELETE statement, SQLite uses an optimization to erase the entire table content without having to visit each row of the table individual. This "truncate" optimization makes the delete run much faster. However, it also means that the sqlite3_changes() interface and the count_changes PRAGMA will not actually return the number of deleted rows. If you need to delete every row of a table and still have sqlite3_changes() and count_changes work correctly, then use WHERE clause that is always true:

DELETE FROM sometable WHERE 1;

This page last modified 2008/08/12 18:08:17 UTC