SET and SET SESSION
On this page
Sets a session variable.
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.
Syntax
SET { [SESSION] variable_name } = value;
SET @@SESSION.variable_name = value;
SET {CHARACTER SET 'charset_name'};
SET PASSWORD FOR 'username'@'host' = PASSWORD('password');
Remarks
-
variable_
is the name of the session variable.name -
The
@@SESSION.
syntax is supported for compatibility with other database systems, such as MySQL.variable_ name -
This command can be run on a master or child aggregator node to set sync variables, but otherwise must be run on the master aggregator.
-
See the engine variables overview for information about other ways to set variables.
-
The
SESSION
keyword is optional.Including it does not change this command’s behavior. -
charset_
sets session system variablesname character_
andset_ client character_
to the given character set, and character_set_ results set_ connection to the value of character_
.set_ server It may be quoted or unquoted. The default character set mapping can be restored by using value DEFAULT
. -
SET PASSWORD
sets the user password.See SET PASSWORD topic for details. -
SET NAMES
is non-operational in SingleStore and is included only for MySQL compatibility.
Warning
Warning: In SingleStore, SET NAMES
, SET CHARSET
, and SET CHARACTER SET
are valid syntax, but are non-operational in SingleStore.
Examples
The following queries set the value of the session variable net_
to 5000.
SET net_read_timeout = 5000;orSET @@SESSION.net_read_timeout = 5000;
The following query retrieves the value of the session variable net_
.
SELECT @@net_read_timeout;
Refer to Assigning Expressions to Variables for more examples.
Related Topics
Last modified: May 21, 2025