First, MySQL default isolation level is repeatable READ
1. Querying a record two times in a transaction, the result is always the value before the start of the transaction. Whether or not another transaction has changed this record,
2. If you save a record in a transaction,
1) If this record has been changed by another already closed transaction, this transaction will overwrite the record.
2) If another transaction changes this record first and does not commit, the transaction will be stuck and waiting. This transaction continues to run until another transaction has ended. The modification affects 0 records, which means that the data is not changed (the equivalent of the modification failed, white changed.) ) (Avoid the second type of update loss)
Second, Oracle default read commited
1. A two-time query for a transaction may be different. Always be able to find the latest.
2. If you save a record in a transaction,
1) If this record has been changed by another already closed transaction, this transaction will overwrite the record. Same as MySQL.
2) If another transaction changes this record first and does not commit, the transaction will be stuck and waiting. This transaction continues to run until another transaction has ended. The difference is that this change will affect the record is not 0, that is, the modification will take effect (overwrite the first transaction modification). (second type of update is missing)
Test code for MySQL
-- ------------------------------Table structure for test-- ----------------------------DROP TABLE IF EXISTS' test ';CREATE TABLE' Test ' (' ID ')int( One)DEFAULT NULL, ' name 'varchar(255)DEFAULT NULL) ENGINE=InnoDBDEFAULTCHARSET=latin1;-- ------------------------------Records of Test-- ----------------------------INSERT into' Test 'VALUES('1','5');INSERT into' Test 'VALUES('2','3');SELECT @ @tx_isolation;SELECT @ @global. tx_isolation;SetSessionTransaction Isolation Level Read committed;SetSessionTransaction Isolation Level Read Uncommitted;SetSessionTransaction Isolation Level Repeatable Read;SetGlobalTransaction Isolation Level Read committed;SetGlobalTransaction Isolation Level Read Uncommitted;SetGlobalTransaction Isolation Level Repeatable Read; startTransaction;Select * fromtest;UpdateTestSetName='2' whereId=2;Select * fromtest;Commit;
View Code
Summary of database transaction isolation levels