• Data Warehouse Service

dws
  1. Help Center
  2. Data Warehouse Service
  3. Developer Guide
  4. SQL Reference
  5. SQL Syntax
  6. SET SESSION AUTHORIZATION

SET SESSION AUTHORIZATION

Function

SET SESSION AUTHORIZATION sets the session user identifier and the current user identifier of the current SQL session to a specified user.

Precautions

The session identifier can be changed only when the initial session user has the system administrator rights. Otherwise, the system supports the command only when the authenticated user name is specified.

Syntax

  • SET SESSION AUTHORIZATION sets the session user identifier and the current user identifier of the current session.
    SET [ SESSION | LOCAL ] SESSION AUTHORIZATION role_name PASSWORD 'password';
  • Reset the identifiers of the session and current users to the initially authenticated user names.
    {SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
        | RESET SESSION AUTHORIZATION};

Parameter Description

  • SESSION

    Indicates that the specified parameters take effect for the current session.

    Value range: A string. It must comply with the naming convention rule.

  • LOCALE

    Indicates that the specified command takes effect only for the current transaction.

  • role_name

    User name.

    Value range: A string. It must comply with the naming convention rule.

  • password

    Specifies the password of a role. It must comply with the password convention.

  • DEFAULT

    Reset the identifiers of the session and current users to the initially authenticated user names.

Examples

-- Create role paul:
CREATE ROLE paul IDENTIFIED BY 'Bigdata123@';

-- Set the current user to paul:
SET SESSION AUTHORIZATION paul password 'Bigdata123@';

-- View the current session user and the current user:
SELECT SESSION_USER, CURRENT_USER;

-- Reset the current user:
RESET SESSION AUTHORIZATION;

-- Delete the user:
DROP USER paul;

Helpful Links

SET ROLE