Create Users, Schemas, and Roles in a Database User Group
A database user group administrator can create users, schemas, and roles to organise and staff their group. Creating schemas and roles and granting, revoking, and dropping roles require the use of SAP Datasphere stored procedures.
Prerequisites
To create users, schemas, and roles in a database user group, you must have a database user group administrator and a password (Creating a Database User Group).
Log In With Your Database User Group Administrator
To connect to SAP HANA Cloud with the administrator, select your newly created user group in the list, and click Open Database Explorer, enter the password when requested, and click OK.
The SAP HANA database explorer opens with your database user group at the top level. You can now use the SQL editor to create users, roles and schemas.
select * from effective_privileges where user_name = current_user;
Create a User
CREATE USER <user_name> PASSWORD <pwd> SET USERGROUP <DBgroup_name>In our example, we create a new user, DWCDBGROUP#DWMIGRATE#BOB, in our DWMIGRATE group:
CREATE USER DWCDBGROUP#DWMIGRATE#BOB password “Welcome1” set usergroup “DWCDBGROUP#DWMIGRATE”;
Create a Schema
CALL "DWC_GLOBAL"."CREATE_USERGROUP_SCHEMA" ( SCHEMA_NAME => '<schema_name>', OWNER_NAME => '<user_name>' );The owner of the new schema must be a user of the database user group. If the owner name is set to null, then the database user group administrator is set as the owner.
CALL "DWC_GLOBAL"."CREATE_USERGROUP_SCHEMA" ( SCHEMA_NAME => 'DWCDBGROUP#DWMIGRATE#STAGING, OWNER_NAME => 'DWCDBGROUP#DWMIGRATE#BOB' );
Create a Role
CALL "DWC_GLOBAL"."CREATE_USERGROUP_ROLE" ( ROLE_SCHEMA_NAME => '<schema_name>', ROLE_NAME => '<role_name>' );Once the role is created, you can grant it to a user or to another role, revoke it, and drop it.
CALL "DWC_GLOBAL"."CREATE_USERGROUP_ROLE" ( ROLE_SCHEMA_NAME => 'DWCDBGROUP#DWMIGRATE#STAGING', ROLE_NAME => 'DWCDBGROUP#DWMIGRATE#DWINTEGRATOR' );
Grant a Role to a User or to Another Role
CALL "DWC_GLOBAL"."GRANT_USERGROUP_ROLE" ( ROLE_SCHEMA_NAME => '<schema_name>', ROLE_NAME => '<role_name>', GRANTEE => '<user_name>', GRANTEE_ROLE_NAME => NULL, WITH_ADMIN_OPTION => FALSE );
The role schema, grantee, and grantee role must all be in the same database user group.
CALL "DWC_GLOBAL"."GRANT_USERGROUP_ROLE" ( ROLE_SCHEMA_NAME => 'DWCDBGROUP#DWMIGRATE#STAGING', ROLE_NAME => 'DWCDBGROUP#DWMIGRATE#DWINTEGRATOR', GRANTEE => 'DWCDBGROUP#DWMIGRATE#BOB', GRANTEE_ROLE_NAME => NULL, WITH_ADMIN_OPTION => FALSE );
Revoke a Role
CALL "DWC_GLOBAL"."REVOKE_USERGROUP_ROLE" ( ROLE_SCHEMA_NAME => '<schema_name>', ROLE_NAME => '<role_name>', GRANTEE => '<user_name>', GRANTEE_ROLE_NAME => NULL );In our example, we revoke the DWCDBGROUP#DWMIGRATE#DWINTEGRATOR role from BOB:
CALL "DWC_GLOBAL"."REVOKE_USERGROUP_ROLE" ( ROLE_SCHEMA_NAME => 'DWCDBGROUP#DWMIGRATE#STAGING', ROLE_NAME => 'DWCDBGROUP#DWINTEGRATOR', GRANTEE => 'DWCDBGROUP#DWMIGRATE#BOB', GRANTEE_ROLE_NAME => NULL );
Drop a Role
CALL "DWC_GLOBAL"."DROP_USERGROUP_ROLE"
(
ROLE_SCHEMA_NAME => '<schema_name>',
ROLE_NAME => '<role_name>'
);
In our example, we drop the DWCDBGROUP#DWMIGRATE#DWINTEGRATOR role:
CALL "DWC_GLOBAL"."DROP_USERGROUP_ROLE"
(
ROLE_SCHEMA_NAME => 'DWCDBGROUP#DWMIGRATE#STAGING',
ROLE_NAME => 'DWCDBGROUP#DWMIGRATE#DWINTEGRATOR'
);