Overview
tx_read_only is used to control the read/write mode of a transaction, that is, whether the transaction is a read-only transaction.
Privilege requirements
Query variables
Global level
The
systenant and all user tenants can use theSHOW VARIABLESstatement and theinformation_schema.GLOBAL_VARIABLESview to view the values of global system variables.Session level
Both the
systenant and all user tenants can use theSHOW VARIABLESstatement and theinformation_schema.SESSION_VARIABLESview to view the values of session system variables.
Modify variables
Global effective
The
systenant can directly modify the values of global system variables.The user tenant must have the
SUPERorALTER SYSTEMprivilege to modify the value of a global system variable.
Session expiration
The
systenant and all user tenants can directly modify the values of session system variables for their own tenants.
Attributes
Attribute |
Description |
|---|---|
| Parameter type | Int |
| Default Value | 0 |
| Value range |
|
| Effective Scope |
|
| Modifiable | Yes, you can use theSETStatement modification. |
Usage instructions
After the system variable tx_read_only is successfully set:
If it takes effect at the session level, it only affects the current user and does not affect other users.
If it takes effect at the global level, it will affect all users on all subsequent new connections.
Configuration example
Sets the transaction to read-only.
Session effective
obclient> SET tx_read_only = 1;Effective globally
obclient> SET GLOBAL tx_read_only = 1;