Skip to main content

Modify system variables

You can set system variables to make seekdb behave as required by your business. This topic describes how to modify system variables.

You can use the SET statement to modify system variables.

  • Session-level variables take effect only in the current session.
  • Global-level variables take effect only after you log in again and create a new session.

In the following example, the ob_query_timeout variable specifies the query timeout period for an SQL statement, in microseconds. You can increase the value of ob_query_timeout to avoid query timeout during a large-scale data query.

Modify a session-level system variable

  1. Log in to seekdb.

    The following example shows how to connect to the database. In your actual environment, you must use the actual connection information.

    mysql -h127.xx.xx.xx -P2881 -uroot -p***** -A
  2. Query session-level system variables.

    SHOW VARIABLES LIKE 'ob_query_timeout';

    The query result is as follows:

    +------------------+----------+
    | Variable_name | Value |
    +------------------+----------+
    | ob_query_timeout | 10000000 |
    +------------------+----------+
    1 row in set
  3. Use the SET statement to modify the value of a session-level system variable.

    SET ob_query_timeout = 20000000;
  4. View the modified value.

    SHOW VARIABLES WHERE variable_name LIKE 'ob_query_timeout';

    The query result is as follows:

    +------------------+----------+
    | Variable_name | Value |
    +------------------+----------+
    | ob_query_timeout | 20000000 |
    +------------------+----------+
    1 row in set

Modify a global-level system variable

  1. Log in to seekdb.

    The following example shows how to connect to the database. In your actual environment, you must use the actual connection information.

    mysql -h127.xx.xx.xx -P2881 -uroot -p***** -A
  2. Query global variables.

    SHOW GLOBAL VARIABLES WHERE variable_name LIKE  'ob_query_timeout';

    The query result is as follows:

    +------------------+----------+
    | Variable_name | Value |
    +------------------+----------+
    | ob_query_timeout | 10000000 |
    +------------------+----------+
    1 row in set
  3. Use the SET statement to modify the value of a global-level system variable.

    SET GLOBAL ob_query_timeout = 20000000;
  4. View the modified value.

    SHOW GLOBAL VARIABLES WHERE variable_name LIKE 'ob_query_timeout';

    The query result is as follows:

    +------------------+----------+
    | Variable_name | Value |
    +------------------+----------+
    | ob_query_timeout | 20000000 |
    +------------------+----------+
    1 row in set

    After the modification is successful, you can query the DBA_OB_SYS_VARIABLES view to view the detailed modification information and default value of the ob_query_timeout variable. The query statement is as follows.

    SELECT * FROM oceanbase.DBA_OB_SYS_VARIABLES WHERE NAME='ob_query_timeout';

    The query result is as follows:

    +----------------------------+----------------------------+------------------+----------+-----------+-----------+------------------+----------------------------------+---------------+-----------+
    | CREATE_TIME | MODIFY_TIME | NAME | VALUE | MIN_VALUE | MAX_VALUE | SCOPE | INFO | DEFAULT_VALUE | ISDEFAULT |
    +----------------------------+----------------------------+------------------+----------+-----------+-----------+------------------+----------------------------------+---------------+-----------+
    | 2025-11-19 16:55:28.311760 | 2025-12-11 15:50:59.153465 | ob_query_timeout | 20000000 | | | GLOBAL | SESSION | Query timeout in microsecond(us) | 10000000 | NO |
    +----------------------------+----------------------------+------------------+----------+-----------+-----------+------------------+----------------------------------+---------------+-----------+
    1 row in set

Modify a boolean system variable

You can use any of the following methods to set the value of a boolean system variable displayed as ON/OFF in the SHOW VARIABLES statement:

SET foreign_key_checks = ON;
SET foreign_key_checks = TRUE;
SET foreign_key_checks = 1;

SET GLOBAL foreign_key_checks = OFF;
SET GLOBAL foreign_key_checks = FALSE;
SET GLOBAL foreign_key_checks = 0;
info

Setting the value of a boolean system variable by using ON/OFF, TRUE/FALSE, or 1/0 is equivalent.

References