System variables
The system variables of OceanBase Database are divided into global variables and session variables. You can set system variables to meet business requirements.
- Global variables: Global variables are modified at the global level. All users of OceanBase Database share global variables. The modification of global variables does not take effect after the session ends. In addition, the modification of global variables does not take effect on sessions that are already open. You must reestablish a session for the modification to take effect.
- Session variables: Session variables are modified at the session level. When a client connects to OceanBase Database, OceanBase Database automatically generates session variables by copying global variables. The modification of session variables takes effect only on the current session.
The following table describes the differences between system variables and system parameters.
| Item | System parameter | System variable |
|---|---|---|
| Scope | Instance | Global or session |
| Effective method |
|
|
| Modification method |
| You can modify a system variable by using an SQL statement. Example: SET ob_query_timeout = 20000000; or SET GLOBAL ob_query_timeout = 20000000; |
| Query method | You can execute the SHOW PARAMETERS statement to query system parameters. Example: SHOW PARAMETERS LIKE 'schema_history_expire_time'; | You can execute the SHOW [GLOBAL] VARIABLES statement to query system variables. Example: SHOW VARIABLES LIKE 'ob_query_timeout'; or SHOW GLOBAL VARIABLES LIKE 'ob_query_timeout'; |
| Lifetime | Long: from the time when the process starts to the time when it exits. | Short: takes effect only after a schema is created. |