Small. Fast. Reliable.
Choose any three.

About Sitemap Documentation Download License News Developers Support

## SQLite C Interface

### Count The Number Of Rows Modified

>     int sqlite3_changes(sqlite3*);

This function returns the number of database rows that were changed or inserted or deleted by the most recently completed SQL statement on the connection specified by the first parameter. Only changes that are directly specified by the INSERT, UPDATE, or DELETE statement are counted. Auxiliary changes caused by triggers are not counted. Use the sqlite3_total_changes() function to find the total number of changes including changes caused by triggers.

Within the body of a trigger, the sqlite3_changes() interface can be called to find the number of changes in the most recently completed INSERT, UPDATE, or DELETE statement within the body of the same trigger.

All changes are counted, even if they are later undone by a ROLLBACK or ABORT. Except, changes associated with creating and dropping tables are not counted.

If a callback invokes sqlite3_exec() or sqlite3_step() recursively, then the changes in the inner, recursive call are counted together with the changes in the outer call.

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 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.

If another thread makes changes on the same database connection while this routine is running then the return value of this routine is undefined.

See also lists of Objects, Constants, and Functions.

This page last modified 2007/12/14 14:37:57 UTC