What is a transaction

Source: Internet
Author: User

Transactions can be defined in many, many different ways. In fact, a transaction is a unit of work performed by a database operation.

Transaction Characteristics

In a database system, a transaction refers to a complete logical process consisting of a series of database operations. For example, bank transfer, deduction of the amount from the original account, and the addition of the amount to the target account, the sum of the two database operations, constitutes a complete logical process that cannot be split. This process is called a transaction and has an acid characteristic.

    • Atomicity (atomicity): All operations in a transaction (transaction) are either complete or not complete and do not end up in the middle of a link. When an error occurs during execution, the transaction is rolled back (Rollback) to the state before the transaction begins, as if the transaction had never been executed.
    • Consistency (consistency): the integrity of the database is not compromised until the transaction begins and after the transaction has ended. This means that the data being written must fully conform to all of the preset rules, which include the accuracy of the data, the concatenation, and the subsequent database's ability to perform the scheduled work spontaneously.
    • Isolation (Isolation): the interrelationship that occurs when two or more transactions concurrently access the same data in a database that refers to queries and modified operations. Transaction isolation is divided into different levels, including read UNCOMMITTED, Read Committed, REPEATABLE READ (repeatable Read), and serialization (Serializable).
    • Persistence (Durability): After the transaction completes, the transaction changes made to the database are persisted in the database and are complete.

transaction type

    • Automatically committed transactions--Each individual statement is a transaction
    • Show declared transactions-this transaction is marked with BEGIN Tran, and is rollback TRAN or a commit tran the end of the statement.
    • Implied transaction - SQL Server starts a new transaction automatically after the current transaction is committed or rolled back, and the new transaction is started by the system when the user executes commit or rollback. This creates a continuous chain of transactions.

SQL Server common transaction operations contain three types of

    • Begin TRANSACTION--transaction start checkpoint
    • ROLLBACK TRANSACTION--rollback of data to the beginning of a transaction due to an error
    • COMMIT TRANSACTION--Save the data to the database

What is a 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.