(4) Transaction Processing SQLite supports transaction processing. If you know that you want to delete a lot of data synchronously, do not make them into a unified transaction. # P4 T's + ~ $ K: R
1 N4 K: ''f * u: U! T a sqlite3_exec is usually a transaction. If you want to delete 10 thousand pieces of data, SQLite will do 10 thousand times: start a new transaction-> delete a piece of data-> commit a transaction-> Start a new transaction->... . This operation is very slow. Because time is spent on starting and committing transactions. (N'a-[* Y-D /~ 'N! O
8 G' V. O "e0 y U1 B -~ 4 | you can make these similar operations into a transaction, so that if the operation is incorrect, you can roll back the transaction. 3 C, P9 ^ 3 m-W
B7 '(Y; ^ +' % Q6 | 3 Y/n transactions do not have special interface functions. It is just a common SQL statement: $ C + @ 6 h-B "M * I; K * z
# | '@ # \ "B H # H5] 1 R:
Copy content to clipboard
Code:
Int result;
Result = sqlite3_exec (dB, "begin transaction", 0, 0, & zerrormsg); // start a transaction
Result = sqlite3_exec (dB, "Commit transaction", 0, 0, & zerrormsg); // submit the transaction
Result = sqlite3_exec (dB, "rollback transaction", 0, 0, & zerrormsg); // roll back the transaction