MySQL SET TRANSACTION isolation level

Source: Internet
Author: User

The user can use the SET TRANSACTION statement to change the isolation level of a single session or all new incoming connections. Its syntax is as follows:

SET [SESSION | GLOBAL] TRANSACTION Isolation Level {READ UNCOMMITTED | READ COMMITTED | Repeatable READ | SERIALIZABLE}

Note: The default behavior (without session and global) is to set the isolation level for the next (not started) transaction. If you use the Global keyword, the statement sets the default transaction level globally for all new connections created from that point, except for connections that do not exist. You need super privilege to do this. Use the session keyword to set the default transaction level for future transactions performed on the current connection. Any client can freely change the session isolation level (even in the middle of a transaction) or set the isolation level for the next transaction.

You can query the global and session transaction isolation levels with the following statement:

SELECT @ @global. tx_isolation;
SELECT @ @session. tx_isolation;
SELECT @ @tx_isolation;

Someone on the web uses the Set tx_isolation command:

mysql> set tx_isolation= ' read-committed ';
Query OK, 0 rows Affected (0.00 sec)

+----------------+
| @ @tx_isolation |
+----------------+
| read-committed |
+----------------+
1 row in Set (0.00 sec)

Mysql> SELECT @ @session. tx_isolation;
+------------------------+
| @ @session. tx_isolation |
+------------------------+
| read-committed |
+------------------------+
1 row in Set (0.00 sec)

Transaction isolation has changed.

Someone else on the web wrote the SET @ @tx_isolation command, but this command is problematic.

mysql> SET @ @tx_isolation =' read-committed ';
Query OK, 0 rows Affected (0.00 sec)

Mysql> SELECT @ @session. tx_isolation;
+------------------------+
| @ @session. tx_isolation |
+------------------------+
| Repeatable-read |
+------------------------+
1 row in Set (0.00 sec)

Mysql> SELECT @ @tx_isolation;
+-----------------+
| @ @tx_isolation |
+-----------------+
| Repeatable-read |
+-----------------+
1 row in Set (0.00 sec)

The isolation level of the session does not change.


MySQL SET TRANSACTION isolation level

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.