Setting up roles for users

Creating roles for users

To create the analyst role, run the query:

CREATE ROLE analyst;

Assigning roles to users

To assign the tengri_user user the analyst role, run the query:

GRANT ROLE analyst TO tengri_user;

Granting privileges

To grant the analyst role read and write privileges within the analytical_sandbox schema, run the query:

GRANT
    USAGE,
    CREATE TABLE,
    CREATE VIEW
ON SCHEMA analytical_sandbox
TO ROLE analyst;

After that, all users with the analyst role will have read and modify privileges for tables and views within the analytical_sandbox schema.

If necessary, adjust the list of granted privileges for this role.

You can grant privileges both to roles and to users directly.
  • Read more about granting privileges to roles or users.

Revoking privileges

To revoke the analyst role’s privilege to create tables in the analytical_sandbox schema, run the query:

REVOKE
    CREATE TABLE
ON SCHEMA analytical_sandbox
FROM ROLE analyst;

If necessary, adjust the list of revoked privileges for this role.

You can revoke privileges from roles as well as from users directly.
  • Read more about revoking privileges from roles or users.

Revoking roles from users

To revoke the analyst role from the user tengri_user, run the query:

REVOKE ROLE analyst FROM USER tengri_user;