ALTER SESSION SET

View as Markdown

Change a parameter value for the current session.

1ALTER SESSION SET <parameter_name>=<parameter_value>
Paremeter nameValues
EXECUTOR_DEVICE

CPU - Set the session to CPU execution mode:

ALTER SESSION SET EXECUTOR_DEVICE=‘CPU’;

GPU - Set the session to GPU execution mode:

ALTER SESSION SET EXECUTOR_DEVICE=‘GPU’;

NOTE: These parameter values have the same effect as the \cpu and \gpu commands in heavysql, but can be used with any tool capable of running sql commands.

CURRENT_DATABASE

Can be set to any string value.

If the value is a valid database name, and the current user has access to it, the session switches to the new database.

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.

Alter Session Examples

CURRENT_DATABASE

Switch to another database without need of re-login.

1ALTER 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:

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

The database does not exist:

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

EXECUTOR_DEVICE

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

1ALTER SESSION SET EXECUTOR_DEVICE='CPU';

Switch back the session to run in GPU mode

1ALTER SESSION SET EXECUTOR_DEVICE='GPU';