## Module 3: Modifying Session Only System Variables

[`tidb_allow_remove_auto_inc`](https://docs.pingcap.com/tidb/stable/system-variables#tidb_allow_remove_auto_inc) is one of the session system variables, modify it and observe the result.

### Step 1. Setup the connections

+ Open three SSH connections to your lab virtual machine, by clicking:
  + [Terminal 1](ssh://monitor1-ssh#1)
  + [Terminal 2](ssh://monitor1-ssh#2)
  + [Terminal 3](ssh://monitor1-ssh#3)

- In [Terminal 1](ssh://monitor1-ssh#1), connect to TiDB server 2:

  ```bash
  ./connect-db2.sh
  ```

  ```output
  ...
  tidb:db1>
  ```

- In [Terminal 2](ssh://monitor1-ssh#2), connect to TiDB server 1:

  ```bash
  ./connect-db1.sh
  ```

  ```output
  ...
  tidb:db1>
  ```

- In [Terminal 3](ssh://monitor1-ssh#3), connect to TiDB server 2:

  ```bash
  ./connect-db2.sh
  ```

  ```output
  ...
  tidb:db2>
  ```

### Step 2. In terminal 1, change `tidb_allow_remove_auto_inc` to `ON`

- In [Terminal 1](ssh://monitor1-ssh#1), execute the following commands.

  ```sql
  SHOW SESSION VARIABLES LIKE 'tidb_allow_remove_auto_inc';
  ```

  ```output
  tidb:db2> SHOW SESSION VARIABLES LIKE 'tidb_allow_remove_auto_inc';
  +----------------------------+-------+
  | Variable_name              | Value |
  +----------------------------+-------+
  | tidb_allow_remove_auto_inc | OFF   |
  +----------------------------+-------+
  1 row in set (0.00 sec)
  ```

  ```sql
  SET SESSION tidb_allow_remove_auto_inc=ON;
  ```

  ```output
  tidb:db2> SET SESSION tidb_allow_remove_auto_inc=ON;
  Query OK, 0 rows affected (0.00 sec)
  ```

  ```sql
  SHOW SESSION VARIABLES LIKE 'tidb_allow_remove_auto_inc';
  ```

  ```output
  tidb:db2> SHOW SESSION VARIABLES LIKE 'tidb_allow_remove_auto_inc';
  +----------------------------+-------+
  | Variable_name              | Value |
  +----------------------------+-------+
  | tidb_allow_remove_auto_inc | ON    |
  +----------------------------+-------+
  1 row in set (0.00 sec)
  ```

### Step 3. In terminal 2, check the value of `tidb_allow_remove_auto_inc`

- Switch to [Terminal 2](ssh://monitor1-ssh#2), execute the following commands.

  ```sql
  SHOW SESSION VARIABLES LIKE 'tidb_allow_remove_auto_inc';
  ```

  ```output
  tidb:db1> SHOW SESSION VARIABLES LIKE 'tidb_allow_remove_auto_inc';
  +----------------------------+-------+
  | Variable_name              | Value |
  +----------------------------+-------+
  | tidb_allow_remove_auto_inc | OFF   |
  +----------------------------+-------+
  1 row in set (0.01 sec)
  ```

### Step 4. In terminal 3, check the value of `tidb_allow_remove_auto_inc`

- Switch to [Terminal 3](ssh://monitor1-ssh#3), execute the following commands.

  ```sql
  SHOW SESSION VARIABLES LIKE 'tidb_allow_remove_auto_inc';
  ```

  ```output
  tidb:db2> SHOW SESSION VARIABLES LIKE 'tidb_allow_remove_auto_inc';
  +----------------------------+-------+
  | Variable_name              | Value |
  +----------------------------+-------+
  | tidb_allow_remove_auto_inc | OFF   |
  +----------------------------+-------+
  1 row in set (0.00 sec)
  ```

### Step 5. In any terminal, change the value of `tidb_allow_remove_auto_inc`

+ Try to change the value of `tidb_allow_remove_auto_inc` in global scope.

  ```sql
  SET GLOBAL tidb_allow_remove_auto_inc=ON;
  ```

  ```output
  tidb:db2> SET GLOBAL tidb_allow_remove_auto_inc=ON;
  ERROR 1228 (HY000): Variable 'tidb_allow_remove_auto_inc' is a SESSION variable and can't be used with SET GLOBAL
  ```

### Step 6. In terminal 1, change `tidb_allow_remove_auto_inc` back to `OFF`

  ```sql
  SET SESSION tidb_allow_remove_auto_inc=OFF;
  ```

  ```output
  tidb:db2> SET SESSION tidb_allow_remove_auto_inc=OFF;
  Query OK, 0 rows affected (0.00 sec)
  ```

### Summary

The session-only TiDB system variable can only be configured on a session level, and its effects will be applied to the current session that you issued the `SET SESSION` statement.
