Database-Database transactions

Source: Internet
Author: User
Tags rollback

A transaction is a user-defined sequence of database operations that is either done or not, and is a non-partitioned unit of work.

Statements that define transactions

BEGIN TRANSACTION;

Commit,----all actions to commit a transaction

rollback;----ROLLBACK: A failure occurred during a transaction cloud, the transaction cannot continue, and the system revokes all completed operations on the data in the transaction, rolling back to the state at the beginning of the transaction.

ACID Properties of transactions

  Atomicity: atomicity

A transaction is a logical unit of work for a database, and operations included in a transaction are either done or not

  Consistency: Consistency

The result of a transaction must be to make the database transition from one consistent state to another.

When the database contains only the results of a successful transaction submission, the database is in a consistent state. If a database system fails in operation and some transactions have not yet been completed, some of the modifications made to the data by these outstanding transactions have been written to the physical database, when the database is in an incorrect state or in an inconsistent state.

A business in a bank, a person who transfers from a account to a B account can be defined as a transaction, including two operations: an operation to withdraw 10000 yuan from a account, an operation to add $10000 to the B account. These two operations are either full, or do not do, so that the database will remain consistent, if only one operation, the logic of fire operations, reduce or increase 1000 yuan.

Isolation: Isolation

The execution of one transaction cannot be interfered with by other transactions, the internal operation of a transaction and the data used are isolated to other transactional transactions and cannot interfere with each other concurrently.

Persistent permanence

Once a transaction is committed, the changes to the data in the database are permanent. The next operation or failure should not have any effect on its execution results.

Database-Database transactions

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.