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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

changes()  |  total_changes()

Return value

An integer.

Examples

Rows changed by an UPDATETry it yourself
UPDATE products SET stock = stock + 10 WHERE category_id = 1;
SELECT changes() AS rows_updated;

Output

rows_updated
3
Rows removed by a DELETETry it yourself
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.

Was this page helpful?