(1) What is a transaction? The role of the transaction: to ensure that a set of operations either succeed or fail at the same time during the process. 1. Purpose: Keep the data consistent in the case of multiple concurrency. 2. Purpose: If an incorrect operation occurs, it can be corrected
(2) What are the characteristics of transactions? Transaction characteristics (ACID) atomicity: A transaction is the smallest unit of execution and cannot be divided. Consistency: The data must be consistent before and after the transaction is specified. Persistence: Once the transaction is committed or rolled back, the lasting change in the database. Isolation: Isolation is used to ensure that multiple users operate the same data in the database without interference.
Concurrency issues that occur when transactions are not isolated
(1) Dirty read: One transaction reads another transaction and has not yet submitted data.
(2) Non-repeatable read: The data read multiple times in a transaction is inconsistent. One transaction reads the modified data of another transaction.
(3) Phantom read (virtual read): A transaction reads the data of insert.