Small. Fast. Reliable.
Choose any three.

SQLite C Interface

Total Number Of Rows Modified

int sqlite3_total_changes(sqlite3*);

This function returns the number of row changes caused by INSERT, UPDATE or DELETE statements since the database handle was opened. The count includes all changes from all trigger contexts. But the count does not include changes used to implement REPLACE constraints, do rollbacks or ABORT processing, or DROP table processing. The changes are counted as soon as the statement that makes them is completed (when the statement handle is passed to sqlite3_reset() or sqlite3_finalize()).

SQLite implements the command "DELETE FROM table" without a WHERE clause by dropping and recreating the table. (This is much faster than going through and deleting individual elements form the table.) Because of this optimization, the change count for "DELETE FROM table" will be zero regardless of the number of elements that were originally in the table. To get an accurate count of the number of rows deleted, use "DELETE FROM table WHERE 1" instead.

See also the sqlite3_changes() interface.

Invariants:

F12261 The sqlite3_total_changes() returns the total number of row changes caused by INSERT, UPDATE, and/or DELETE statements on the same database connection, in any trigger context, since the database connection was created.

Limitations:

U12264 If a separate thread makes changes on the same database connection while sqlite3_total_changes() is running then the value returned is unpredictable and unmeaningful.

See also lists of Objects, Constants, and Functions.


This page last modified 2008/01/31 20:37:13 UTC