# 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';
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.heavy.ai/v8.3.0/sql/data-manipulation-dml/sql-capabilities/alter-session-set.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
