2 2 Votes

SQLite: How many rows were affected by an UPDATE or DELETE?

Info by SmartUser | 08/11/2013 at 00:37

Question: We have performed an UPDATE or a DELETE request in our SQLite database. Now we are interested in how many rows from our table have been infected by this. For example, to check whether there were made any changes at all.

Solution: The function changes() helps us in this case. It gives us the number of rows that were affected by the last INSERT, DELETE or UPDATE statement. A call might look like this:

SELECT changes() FROM tab

If you have performed an INSERT, DELETE or UPDATE on the table "tab" before calling this command, the expression gives us the number of rows affected.

If we are interested in the total number of affected rows since connecting to the database, we can use the function total_changes() instead of changes() for this.

ReplyPositiveNegative

About the Author

Avatar AuthorThe author has not added a short description to his profile yet.
Show Profile | Message

 

Related Topics

SQLite: Reset AUTOINCREMENT
Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.