1.
Transaction Concept _ four characteristics
First, the business
The concept of a transaction : A transaction is a logical set of operations that either completes at the same time or is not completed at the same time .
Management of transactions : By default , the database automatically manages transactions , which is managed by a single statement that is exclusive of a transaction .
If you need to control the transaction yourself, you can also open / commit / rollback the transaction with the following command
Start transaction;
Commit
Rollback
managing transactions in JDBC :
Conn.setautocommit (FALSE);
Conn.commit ();
Conn.rollback ();
SavePoint sp = Conn.setsavepoint ();
Conn.rollback (SP);
Four characteristics of a transaction: the most basic feature of a transaction , a well-designed database can help us ensure that transactions have these four characteristics (ACID)
1. Atomic Nature : atomicity means that a transaction is an inseparable unit of work, and the operations in the transaction either occur or do not occur.
2 consistency So after the end of the transaction ,
Integrity State of the database : When all the data in a database conforms to all the constraints defined in the database , It can be said that the database is an integrity state .
3. isolation : the isolation of transactions means that when multiple users access the database concurrently, the transaction of one user cannot be interfered by other users ' transactions, and the data between multiple concurrent transactions is isolated from each other.
4. Durability : persistence refers to the fact that once a transaction is committed, it changes the data in the database to be permanent, and then it should not have any effect even if the database fails.
Isolation :
The design of the database as a single -threaded database prevents all thread-safety issues and naturally ensures isolation . But if the database is designed like this , then the efficiency will be extremely low . .
Transaction Concept _ Four characteristics