Small. Fast. Reliable.
Choose any three.

About Sitemap Documentation Download License News Developers Support

## 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 connection was opened. The count includes all changes from all trigger contexts. However, 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 from the table.) Because of this optimization, the deletions in "DELETE FROM table" are not row changes and will not be counted by the sqlite3_changes() or sqlite3_total_changes() functions, 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. Or recompile using the SQLITE_OMIT_TRUNCATE_OPTIMIZATION compile-time option to disable the optimization on all queries.

See also the sqlite3_changes() interface.

### Invariants:

H12261 | 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.
H12263 | Statements of the form "DELETE FROM tablename" with no WHERE clause shall not change the value returned by sqlite3_total_changes().

### Assumptions:

A12264 | If a separate thread makes changes on the same database connection while sqlite3_total_changes() is running then the value returned is unpredictable and not meaningful.

See also lists of Objects, Constants, and Functions.

This page last modified 2008/12/09 18:44:04 UTC