# SET and SET SESSION

Sets a session variable. Its value remains in effect for the duration of the current database connection.

> **⚠️ Warning**: SingleStore recommends using the `SET SESSION` statement for session variables that are only referenced by the aggregator nodes on which the variable is set. For session variables with values that need to be propagated to leaf nodes from the aggregator nodes, use a global setting instead.

## Syntax

```sql
SET [SESSION] variable_name = value;
SET @@SESSION.variable_name = value;
```

## Arguments

* `variable_name`: Name of the session variable to configure.
* `value`: The session variable's value.

## Remarks

* The `SESSION` keyword is optional. Including it does not change this command’s behavior.
* The `@@SESSION.variable_name` syntax is supported for compatibility with other database systems, such as MySQL.
* This command can be run on a Master or Child aggregator node to set [sync variables](https://docs.singlestore.com/cloud/reference/configuration-reference/engine-variables/sync-variables.md), but otherwise must be run on the Master Aggregator.
* Refer to [Engine Variables](https://docs.singlestore.com/cloud/reference/configuration-reference/engine-variables.md) for information on other ways to set variables.
* `SET PASSWORD` sets the user password. Refer to [SET PASSWORD](https://docs.singlestore.com/cloud/reference/sql-reference/security-management-commands/set-password.md) topic for details.

> **⚠️ Warning**: `SET NAMES`, `SET CHARSET`, and `SET CHARACTER SET` are non-operational in SingleStore. These commands are included only for MySQL compatibility.

## Examples

The following queries set the value of the session variable `net_read_timeout` to `5000`.

```sql
SET net_read_timeout = 5000;

SET @@SESSION.net_read_timeout = 5000;
```

The following query retrieves the value of the session variable `net_read_timeout`.

```sql
SELECT @@net_read_timeout;
```

Refer to [Assigning Expressions to Variables](https://docs.singlestore.com/cloud/reference/configuration-reference/engine-variables/assigning-expressions-to-variables/#section-idm4545871151977633309679676987.md) for more examples.

## Related Topics

* [Engine Variables Overview](https://docs.singlestore.com/cloud/reference/configuration-reference/engine-variables.md)
* [SET GLOBAL](https://docs.singlestore.com/cloud/reference/sql-reference/operational-commands/set-global.md)

***

Modified at: June 16, 2026

Source: [/cloud/reference/sql-reference/operational-commands/set-and-set-session/](https://docs.singlestore.com/cloud/reference/sql-reference/operational-commands/set-and-set-session/)

(An index of the documentation is available at /llms.txt)
