Home  >  Article  >  Database  >  Learn more about what transactions are in databases and the four characteristics of transactions

Learn more about what transactions are in databases and the four characteristics of transactions

迷茫
迷茫Original
2017-03-26 13:53:081820browse

one. What is a transaction
A transaction is a strict series of operations in an application. All operations must be completed successfully, otherwise all changes made in each operation will be undone. That is to say, transactions are atomic, and a series of operations in a transaction either all succeed or none of them are performed.
There are two ways to end a transaction. When all steps in the transaction are successfully executed, the transaction is committed. If one of the steps fails, a rollback operation occurs, undoing all operations up to the beginning of the transaction.
two. ACID of transactions
Transactions have four characteristics: atomicity (Atomicity), consistency (Consistency), isolation (Isolation) and persistence (Durability). These four properties are simply called ACID properties.
1. Atomicity
Transaction is the logical working unit of the database. All operations included in the transaction are either done or none
2. Consistency
Things The result of task execution must be to change the database from one consistency state to another consistency state. Therefore, a database is said to be in a consistent state when it contains only the results of successful transaction commits. If the database system A failure occurs during operation, and some transactions are forced to be interrupted before they are completed. Some of the modifications made to the database by these unfinished transactions have been written to the physical database. At this time, the database is in an incorrect state, or in other words, it is in an incorrect state. Inconsistent status.
3. Isolation
The execution of a transaction cannot be interfered by other transactions. That is, the operations and data used within a transaction are isolated from other concurrent transactions, and transactions executed concurrently cannot interfere with each other.
4, Persistence
Also known as permanence, it means that once a transaction is submitted, its changes to the data in the database should be permanent. Subsequent other operations or failures should not have any impact on its execution results.

The database system must maintain the following characteristics of transactions (referred to as ACID):

Atomicity (Atomicity)

Consistency (Consistency)

Isolation ( Isolation)

Durability (Durability)

Atomicity (Atomicity)

All operations in the transaction are either all executed or none at all;

If transactions are not guaranteed to be atomic, the database may be in an inconsistent state in the event of a system

failure.

The above is the detailed content of Learn more about what transactions are in databases and the four characteristics of transactions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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