Purpose
Sets the transaction isolation level.
OceanBase Database in MySQL mode supports the Read Committed and Repeatable Read isolation levels. The default isolation level is Read Committed.
You cannot set the isolation level during a transaction. Otherwise, an error will be returned.
ERROR:OBE-01453: SET TRANSACTION must be first statement of transactionWhen the Serializable isolation level is enabled, the Global Timestamp Service (GTS) must be enabled.
The session must maintain the session-level transaction isolation level. When a transaction is started, the session-level transaction isolation level is obtained. This isolation level can be overridden by the transaction-level isolation level.
Syntax
SET [GLOBAL | SESSION | LOCAL] TRANSACTION trans_opt
trans_opt:
transaction_access_mode
| isolation_level
| transaction_access_mode, isolation_level
| isolation_level, transaction_access_mode
transaction_access_mode:
[READ ONLY | READ WRITE]
isolation_level:
ISOLATION LEVEL {
READ UNCOMMITTED
| READ COMMITTED
| REPEATABLE READ
| SERIALIZABLE
}
Parameters
| Parameter | Description |
|---|---|
| GLOBAL | SESSION | LOCAL | Specifies the scope of the transaction isolation level. Default value: empty.
|
| READ ONLY | READ WRITE | Specifies the read/write mode of the transaction. |
| READ UNCOMMITTED | Specifies the transaction isolation level as Read Uncommitted. Note This version does not support setting the transaction isolation level to Read Uncommitted. |
| READ COMMITTED | Specifies the transaction isolation level as Read Committed. |
| REPEATABLE READ | Specifies the transaction isolation level as Repeatable Read. |
| SERIALIZABLE | Specifies the transaction isolation level as Serializable. Note OceanBase Database does not support setting the transaction isolation level of the sys tenant to Serializable. This is because the sys tenant cannot be configured to use the Serializable isolation level. |
Examples
Set the transaction isolation level of the next transaction in the current session to Read Committed.
obclient> SET TRANSACTION ISOLATION LEVEL READ COMMITTED;Set the transaction isolation level of the current session to Repeatable Read.
obclient> SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
