Purpose
Sets the transaction isolation level.
OceanBase AI Database supports two isolation levels: Read Committed and Repeatable Read. The default isolation level is Read Committed.
The isolation level cannot be set during transaction execution; otherwise, an error will be reported.
ERROR:OBE-01453: SET TRANSACTION must be first statement of transactionWhen the serializable isolation level is enabled, you must ensure that the Global Timestamp Service (GTS) is enabled.
The session maintains a session-level transaction isolation level. This isolation level is obtained when a transaction starts and can be overridden by a 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. The default value is empty.
|
| READ ONLY \ | READ WRITE | Specifies the read and write modes of a transaction. |
| READ UNCOMMITTED | Specifies the transaction isolation level as Read Uncommitted. Note The current version does not support setting the transaction isolation level to Read Uncommitted. |
| READ COMMITTED | Specify the transaction isolation level as Read Committed. |
| REPEATABLE READ | Specify the transaction isolation level as Repeatable Read. |
| SERIALIZABLE | Specifies the transaction isolation level as serializable. Note OceanBase AI Database does not support setting the transaction isolation level for the sys tenant to serializable, because it is not possible to create a user tenant in the sys |
Examples
Sets the transaction isolation level for 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;