Home > Database > Mysql Tutorial > What is a database transaction?

What is a database transaction?

清浅
Release: 2020-09-09 11:31:22
Original
28484 people have browsed it

A database transaction is a sequence of database operations that accesses and may operate various data items. These operations are either all executed or none are executed. They are an indivisible unit of work. A transaction consists of all database operations performed between the start and end of a transaction.

What is a database transaction?

【Recommended tutorial: MySQL tutorial

Transactions in the database

A database transaction is a sequence of database operations that accesses and may operate various data items. These operations are either all executed or none are executed. Yes An indivisible unit of work. A transaction consists of all database operations performed between the start and end of a transaction.

A transaction is a series of operations performed as a logical unit. A logical unit of work must have four properties, called ACID (Atomicity, Consistency, Isolation, and Durability) properties. Only in this way can it become A transaction.

Atomicity

Transactions must be atomic units of work; either all or none of their data modifications are executed.

Consistency

When a transaction is completed, all data must be consistent. In the relevant database, all rules must be applied to transaction modifications to maintain the integrity of all data. At the end of the transaction, all internal data structures (such as B-tree indexes or doubly linked lists) must be correct.

Isolation

Modifications made by concurrent transactions must be isolated from modifications made by any other concurrent transactions. The state of the data when a transaction views the data is either the state before it was modified by another concurrent transaction, or the state after another transaction modified it. The transaction will not view the data in the intermediate state. This is called serializability because it enables the starting data to be reloaded and a series of transactions to be replayed so that the data ends in the same state as the original transaction execution.

Persistence

After a transaction is completed, its impact on the system is permanent. This modification will be maintained even if there is a system failure.

The above is the detailed content of What is a database transaction?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template