Four characteristics of database transactions

When the database supports transaction operation, it must meet the four characteristics of transaction ACID

1. Atomicity (A)

    Atomicity means that all operations of a transaction either succeed or fail, and if there is no successful operator, it will roll back to the original state.

2. Consistency (C)

    Consistency means that the database must be guaranteed to be in a complete state before and after the operation.

    The complete state of the database: When all the data in a database conforms to all the constraints defined in the database, the database can be said to be in a complete state.

3. Isolation

    When multiple users access the database concurrently, the transaction operations of each user cannot be interfered by the operations of other transactions, that is, cannot be interfered by uncommitted transactions

4. Persistence

   It means that once a transaction is committed, its impact on the database is permanent

 

If the database is not isolated, the following situations will occur:

1. Dirty reads

   One transaction reads data to another uncommitted transaction

2. Unrepeatable

   In the current transaction, the same record is read successively, and the updated and deleted data submitted by another transaction is read, resulting in different results of the two reads.

3. Phantom reading

   In the current transaction, the data is queried successively according to the same query conditions, and the data just inserted by other transactions is read.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325274559&siteId=291194637