[Database] sqlite3 usage Summary 5

Source: Internet
Author: User
(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.