Skip to content

massGrant ​

Command: massGrant
Category: Mass Operations
Status: Production Ready

Description ​

Grant database privileges to users or roles in bulk. This command allows you to assign the same privilege to a grantee across multiple database objects efficiently, supporting patterns, privilege options, and dry-run mode for validation.

Use Cases ​

  • Permission Setup: Grant SELECT/INSERT/UPDATE/DELETE to users on multiple tables at once
  • Schema Access: Grant privileges on all objects in a schema to new team members
  • Role-based Access: Assign privileges to roles for different user groups
  • Grant Delegation: Use --withGrantOption to allow users to grant privileges to others
  • Access Revocation Planning: Use dry-run mode to preview changes before applying

Supported Privileges ​

PrivilegeDescriptionUse Case
SELECTRead data from objectsAll users needing read access
INSERTAdd new rows to tablesData entry and integration processes
UPDATEModify existing dataData maintenance operations
DELETERemove rows from tablesData cleanup and corrections
EXECUTERun procedures/functionsAutomation and batch processes

Syntax ​

bash
hana-cli massGrant [schema] [object] [options]

Aliases ​

  • mg
  • massgrant
  • massGrn
  • massgrn

Command Diagram ​

Parameters ​

ParameterAliasTypeDefaultRequiredDescription
schemasstring-YesDatabase schema containing objects
objectostring-YesObject name or pattern (use % for all)
granteegstring-YesUser or role to grant privilege to
privilegeprstring-YesPrivilege to grant (SELECT, INSERT, UPDATE, DELETE, EXECUTE)
objectTypet, typestring-NoFilter by object type (TABLE, VIEW, PROCEDURE, etc.)
withGrantOptionwgobooleanfalseNoAllow grantee to grant privilege to others
dryRundr, previewbooleanfalseNoPreview changes without applying
log-booleanfalseNoLog all grant operations

For a complete list of parameters and options, use:

bash
hana-cli massGrant --help

Examples ​

Grant SELECT to User on All Tables ​

bash
hana-cli massGrant --schema MYSCHEMA --object % --grantee DBUSER --privilege SELECT

Preview Grants Before Applying ​

bash
hana-cli massGrant --schema MYSCHEMA --object % --grantee DBUSER --privilege SELECT --dryRun

Grant with Delegation Option ​

bash
hana-cli massGrant --schema MYSCHEMA --object "SALES%" --grantee SALES_ADMIN --privilege SELECT --withGrantOption

Grant Multiple Privileges on Views Only ​

bash
hana-cli massGrant -s MYSCHEMA -o % -t VIEW -g ANALYST -pr SELECT --log
  • massUsers - Create bulk users for development
  • users - Manage individual users
  • roles - Manage database roles

See Also ​