# ALTER SESSION SET

Change a parameter value for the current session.

```sql
ALTER SESSION SET <parameter_name>=<parameter_value>
```

<table><thead><tr><th width="243.0095017060001">Paremeter name</th><th>Values</th></tr></thead><tbody><tr><td>EXECUTOR_DEVICE</td><td><p>CPU - Set the session to CPU execution mode:</p><p><code>ALTER SESSION SET EXECUTOR_DEVICE='CPU';</code><br><br>GPU - Set the session to GPU execution mode:</p><p><code>ALTER SESSION SET EXECUTOR_DEVICE='GPU';</code><br><br><strong>NOTE:</strong> These parameter values have the same effect as the <code>\cpu</code> and <code>\gpu</code> commands in heavysql, but can be used with any tool capable of running sql commands.</p></td></tr><tr><td>CURRENT_DATABASE</td><td><p>Can be set to any string value.</p><p>If the value is a valid database name, and the current user has access to it, the session switches to the new database.<br><br>If the user does not have access or the database does not exist, an error is returned and the session will fall back to the starting database.</p></td></tr></tbody></table>

## Alter Session Examples

### CURRENT\_DATABASE

Switch to another database without need of re-login.

```sql
ALTER SESSION SET CURRENT_DATABASE='owned_database'; 
```

Your session will silently switch to the requested database.

The database exists, but the user does not have access to it:

```sql
ALTER SESSION SET CURRENT_DATABASE='information_schema';
TException - service has thrown: TDBException(error_msg=Unauthorized access: 
user test is not allowed to access database information_schema.)
```

The database does not exist:

```sql
ALTER SESSION SET CURRENT_DATABASE='not_existent_db'; 
TException - service has thrown: TDBException(error_msg=Database name 
not_existent_db does not exist.)
```

### EXECUTOR\_DEVICE

Force the session to run the subsequent SQL commands in CPU mode:

```sql
ALTER SESSION SET EXECUTOR_DEVICE='CPU';
```

Switch back the session to run in GPU mode

```sql
ALTER SESSION SET EXECUTOR_DEVICE='GPU';
```
