Skip to main content

SET TRANSACTION

Description

Sets the transaction isolation level.

seekdb 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 transaction

  • When you enable the Serializable isolation level, you must ensure that the Global Timestamp Service (GTS) is enabled.

  • The session must maintain the transaction isolation level at the session 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 UNCOMMITED
| READ COMMITED
| REPEATABLE READ
| SERIALIZABLE
}

Parameters

ParameterDescription
GLOBAL | SESSION | LOCALThe scope of the transaction isolation level. Default value: empty.
  • GLOBAL: applies to all subsequent sessions and does not affect the current session.
  • SESSION | LOCAL: applies to all subsequent transactions executed in the current session. It does not affect the current ongoing transaction. If executed between transactions, this statement overrides any previous statements that set the named feature for the next transaction.
  • No declaration: applies to the next single transaction executed in the session. Subsequent transactions will revert to using the session-level value for the named feature.
READ ONLY | READ WRITESpecifies the read/write mode of the transaction.
READ UNCOMMITEDSpecifies the transaction isolation level as Read Uncommitted.
Note This version does not support setting the transaction isolation level to Read Uncommitted.
READ COMMITEDSpecifies the transaction isolation level as Read Committed.
REPEATABLE READSpecifies the transaction isolation level as Repeatable Read.
SERIALIZABLESpecifies the transaction isolation level as Serializable.

Examples

  • Set the transaction isolation level of the next transaction in the current session to Read Committed.

    SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
  • Set the transaction isolation level of the current session to Repeatable Read.

    SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;