content_image/794755.jpg
UPDATE t SET b = 4 WHERE b = 2 AND c = 4; 

The READ COMMITTED  isolation level can be set at startup or changed at runtime. At runtime, it can be set globally for all sessions, or individually per session. 

• READ UNCOMMITTED 

SELECT  statements are performed in a nonlocking fashion, but a possible earlier version of a row might be used. Thus, using this isolation level, such reads are not consistent. This is also called a dirty read. Otherwise, this isolation level works like READ COMMITTED . 

• SERIALIZABLE 

This level is like REPEATABLE READ , but InnoDB  implicitly converts all plain SELECT  statements to SELECT ... FOR SHARE  if autocommit  is disabled. If autocommit  is enabled, the SELECT  is its own transaction. It therefore is known to be read only and can be serialized if performed as a consistent (nonlocking) read and need not block for other transactions. (To force a plain SELECT  to block if other transactions have modified the selected rows, disable autocommit .) 

## 15.7.2.2 autocommit, Commit, and Rollback 

<img src='content_image/794755.jpg'>

## Note 

As of MySQL 8.0.22, DML operations that read data from MySQL grant tables (through a join list or subquery) but do not modify them do not acquire read locks on the MySQL grant tables, regardless of the isolation level. For more information, see Grant Table Concurrency. 

In InnoDB , all user activity occurs inside a transaction. If autocommit  mode is enabled, each SQL statement forms a single transaction on its own. By default, MySQL starts the session for each new connection with autocommit  enabled, so MySQL does a commit after each SQL statement if that statement did not return an error. If a statement returns an error, the commit or rollback behavior depends on the error. See Section 15.21.4, “InnoDB Error Handling” . 

A session that has autocommit  enabled can perform a multiple-statement transaction by starting it with an explicit START TRANSACTION  or BEGIN  statement and ending it with a COMMIT  or ROLLBACK statement. See Section 13.3.1, “START TRANSACTION, COMMIT, and ROLLBACK Statements” . 

If autocommit  mode is disabled within a session with SET autocommit = 0 , the session always has a transaction open. A COMMIT  or ROLLBACK  statement ends the current transaction and a new one starts. 

If a session that has autocommit  disabled ends without explicitly committing the final transaction, MySQL rolls back that transaction. 

Some statements implicitly end a transaction, as if you had done a COMMIT  before executing the statement. For details, see Section 13.3.3, “Statements That Cause an Implicit Commit” . 

A COMMIT  means that the changes made in the current transaction are made permanent and become visible to other sessions. A ROLLBACK  statement, on the other hand, cancels all modifications made by the current transaction. Both COMMIT  and ROLLBACK  release all InnoDB  locks that were set during the current transaction. 

## Grouping DML Operations with Transactions 

By default, connection to the MySQL server begins with autocommit mode enabled, which automatically commits every SQL statement as you execute it. This mode of operation might be unfamiliar if you have 

