Skip to main content

Manage privileges for policies

Privilege items

Policy creation and application are controlled by privileges such as CREATE, APPLY, ALTER, and DROP. Administrators can determine whether to delegate these privileges to some departments or roles based on business scenarios.

Privilege itemDescription
CREATE MASKING POLICYCreates a masking policy in a database.
CREATE ROW ACCESS POLICYCreates a row access policy in a data base
APPLYApplies a policy to a table.
ALTERModifies a policy.
DROPDrops a policy.

CREATE MASKING POLICY,CREATE ROW ACCESS POLICY

Controls whether users or roles have the permission to create a policy in a database.

GRANT CREATE MASKING POLICY ON DATABASE <db_name> TO ROLE <role_name>
GRANT CREATE ROW ACCESS POLICY ON DATABASE <db_name> TO ROLE <role_name>

REVOKE CREATE MASKING POLICY ON DATABASE <db_name> FROM ROLE <role_name>
REVOKE CREATE ROW ACCESS POLICY ON DATABASE <db_name> FROM ROLE <role_name>

APPLY

Controls whether users or roles have the permission to apply a policy or apply all policies.

GRANT APPLY ON MASKING POLICY <policy_name> TO ROLE <role_name>
GRANT APPLY ON ROW ACCESS POLICY <policy_name> TO ROLE <role_name>

REVOKE APPLY ON MASKING POLICY <policy_name> FROM ROLE <role_name>
REVOKE APPLY ON ROW ACCESS POLICY <policy_name> FROM ROLE <role_name>
GRANT APPLY ON ALL MASKING POLICIES TO ROLE <role_name>
GRANT APPLY ON ALL MASKING POLICIES IN ALL DATABASES TO ROLE <role_name>

ALTER

Controls whether users or roles have the permission to modify a policy.

GRANT ALTER ON MASKING POLICY <policy_name> TO ROLE <role_name>
GRANT ALTER ON ROW ACCESS POLICY <policy_name> TO ROLE <role_name>

DROP

Controls whether users or roles have the permission to drop a policy.

GRANT DROP ON MASKING POLICY <policy_name> TO ROLE <role_name>
GRANT DROP ON ROW ACCESS POLICY <policy_name> TO ROLE <role_name>

Privileges required for SQL commands

The SQL commands used to create and manage policies require privileges. You can refer to Masking policies and Row access policies for the syntax and examples of these commands.

Masking policy

SQLRequired privilegesGRANT syntax
CREATE MASKING POLICYCREATE MASKING POLICYGRANT CREATE MASKING POLICY ON DATABASE <db_name> TO ROLE <role_name>
ALTER TABLE...SET MASKING POLICYALTER and APPLY
  • GRANT ALTER ON TABLE <table_name> TO ROLE <role_name>
  • GRANT APPLY ON MASKING POLICY <policy_name> to ROLE <role_name>
ALTER TABLE...UNSET MASKING POLICYALTERGRANT ALTER ON TABLE <table_name> TO ROLE <role_name>
ALTER MASKING POLICYALTERGRANT ALTER ON MASKING POLICY <policy_name> to ROLE <role_name>
SHOW MASKING POLICIESNoneNone
SHOW CREATE MASKING POLICYAny of APPLY, ALTER, or DROP
DROP MASKING POLICYDROPGRANT DROP ON MASKING POLICY <policy_name> to ROLE <role_name>

Row access policy

SQLRequired privilegesGRANT syntax
CREATE ROW ACCESS POLICY POLICYCREATE ROW ACCESS POLICYGRANT CREATE ROW ACCESS POLICY ON DATABASE <db_name> TO ROLE <role_name>
ALTER TABLE...ADD ROW ACCESS POLICYALTER and APPLY
  • GRANT ALTER ON TABLE <table_name> TO ROLE <role_name>
  • GRANT APPLY ON ROW ACCESS POLICY <policy_name> to ROLE <role_name>
ALTER TABLE...DROP ROW ACCESS POLICYALTERGRANT ALTER ON TABLE <table_name> TO ROLE <role_name>
ALTER ROW ACCESS POLICYALTERGRANT ALTER ON ROW ACCESS POLICY <policy_name> to ROLE <role_name>
SHOW ROW ACCESS POLICIESNoneNone
SHOW CREATE ROW ACCESS POLICYAny of APPLY, ALTER, or DROP
DROP ROW ACCESS POLICYDROPGRANT DROP ON ROW ACCESS POLICY <policy_name> to ROLE <role_name>

Manage privileges

Three data administration models are supported to realize segregation of duties: centralized, decentralized, and hybrid administration. You can decide how to delegate policy-related privileges to suit your business requirements.

CentralizedHybridDecentralized
CREATESecurity managerSecurity managerIndividual teams
APPLYSecurity managerIndividual teamsIndividual teams
  • Centralized: Only the administrator is allowed to manage policies.

     CREATE ROLE security_manager;

    GRANT CREATE MASKING POLICY ON DATABASE d1 TO ROLE security_manager;

    GRANT APPLY ON ALL MASKING POLICIES ON DATABASE d1 TO ROLE security_manager;
  • Hybrid: Both the administrator and other roles can manage policies.

    CREATE ROLE security_manager;

    GRANT CREATE MASKING POLICY ON DATABASE d1 TO ROLE security_manager;

    GRANT APPLY ON ALL MASKING POLICIES ON DATABASE d1 TO ROLE db_owner;
  • Decentralized: Policies are managed by other roles.

    CREATE ROLE db_owner;

    GRANT CREATE MASKING POLICY ON DATABASE d1 TO ROLE db_owner;

    GRANT APPLY ON ALL MASKING POLICIES ON DATABASE d1 TO ROLE db_owner;