SQLite 3 reference · Conditional and Type Functions
SQLite CHANGES() Function
Return how many rows the most recent INSERT, UPDATE or DELETE changed. total_changes() counts since the connection opened.
SQLite 3
Syntax
changes() | total_changes()
Return value
An integer.
Examples
UPDATE products SET stock = stock + 10 WHERE category_id = 1;
SELECT changes() AS rows_updated;
Output
rows_updated 3
DELETE FROM order_items WHERE order_id IN (1, 2);
SELECT changes() AS rows_deleted;
Output
rows_deleted 4
total_changes() counts every row changed since the connection opened, including rows loaded by earlier
scripts, so use changes() to check the statement you just ran.
Related
LAST_INSERT_ROWID()· Return the rowid of the most recent successful INSERT on this connection, such as a new auto-generated ID.- SQL UPDATE · tutorial