Description
tx_read_only specifies whether to enable the transaction read/write mode for transactions, that is, whether to set the transaction as read-only.
Privilege requirements
Query variables
Global level
In both Oracle and MySQL modes, you can execute the
SHOW VARIABLESstatement or query theSYS.TENANT_VIRTUAL_GLOBAL_VARIABLEview (Oracle mode) orinformation_schema.GLOBAL_VARIABLESview (MySQL mode) to view the values of global system variables from thesystenant and all user tenants.Session level
The
systenant and all user tenants can view the values of session system variables by using theSHOW VARIABLESstatement, or by querying the viewsSYS.TENANT_VIRTUAL_SESSION_VARIABLE(Oracle mode) orinformation_schema.SESSION_VARIABLES(MySQL mode).
Modify variables
Global level
The
systenant can directly modify the values of global system variables.MySQL users of user tenants have the
SUPERorALTER SYSTEMprivilege, which allows them to modify the values of global system variables.For V4.x, starting from V4.2.0, an Oracle user tenant must have the
ALTER SYSTEMprivilege to modify the values of global system variables.
Session level
Both the
systenant and user tenants can directly modify the values of session system variables in their own tenants.
Attributes
| Attribute | Description |
|---|---|
| Parameter type | Int |
| Default value | 0 |
| value |
|
| Scope |
|
| Modifiable | Yes. You can execute the SET statement to modify the value. |
User Guide
After you set the tx_read_only system variable:
If session-level, the setting affects only the current user and does not affect other users.
If this setting takes effect at the global level, it will impact all users for all subsequent new connections.
Examples
Set the transaction to read-only.
Session level
obclient> SET tx_read_only = 1;Global level
obclient> SET GLOBAL tx_read_only = 1;