1. View the current session isolation level
SELECT @ @tx_isolation;
2. View the current isolation level of the system
SELECT @ @global. tx_isolation;
3. Set the current session isolation level
Set session transaction Isolatin level repeatable read;
4. Set the current isolation level of the system
Set global transaction ISOLATION level repeatable read;
5. Command line, when you start a transaction
Set Autocommit=off or start transaction
Understanding of Isolation Levels
1.read UNCOMMITTED
You can see uncommitted data (dirty reads), for example: You believe what people say, but maybe he just says it and doesn't actually do it.
2.read committed
Reads the submitted data. However, data results that may be read multiple times are inconsistent (non-repeatable read, Phantom Read). The reading and writing view is: Read the row data, can write.
3.repeatable Read (MySQL default isolation level)
Can be read repeatedly, but with Phantom read. Read-write view: The data rows read are not writable, but new data can be added to the table. In MySQL, new data for other transactions is not visible and does not produce phantom reads. The multi-version concurrency control (MVCC) mechanism is used to solve the phantom reading problem.
4.serializable
Readable, non-writable. Like a lock in Java, writing data must wait for the end of another transaction.