HomeMogDBMogDB StackUqbar
v3.0

Documentation:v3.0

Supported Versions:

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 statement only when the authenticated user name is specified.

Syntax

  • Set the session user identifier and the current user identifier of the current session.

    SetSessionAuthorization ::= SET [ SESSION | LOCAL ] SESSION AUTHORIZATION role_name PASSWORD 'password';
  • Reset the identifiers of the session and current users to the initially authenticated user names.

    ResetSessionAuthorization ::= {SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
        | RESET SESSION AUTHORIZATION};

Parameter Description

  • SESSION

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

  • LOCAL

    Specifies that the specified statement takes effect only for the current transaction.

  • role_name

    Username

    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

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

Examples

-- Create a role paul.
MogDB=# CREATE ROLE paul IDENTIFIED BY 'Bigdata@123';

-- Set the current user to paul.
MogDB=# SET SESSION AUTHORIZATION paul password 'Bigdata@123';

-- View the current session user and the current user.
MogDB=# SELECT SESSION_USER, CURRENT_USER;

-- Reset the current user.
MogDB=# RESET SESSION AUTHORIZATION;

-- Delete the user.
MogDB=# DROP USER paul;

SET ROLE

Copyright © 2011-2024 www.enmotech.com All rights reserved.