Share data protected by a policy¶

Data sharing consumers can use a shared database role to access shared data protected by a masking policy or a row access policy.

Overview¶

A data sharing provider can share a database role to enable a data sharing consumer to access policy protected data. The provider defines the policy to call the IS_DATABASE_ROLE_IN_SESSION function to evaluate the shared database role or a mapping table column that contains the database role. This provides more options to the provider to share data and allows the consumer to access sensitive data that the provider makes available.

When the policies and protected tables are in different databases, the provider must:

  • Create the database role in the same database as the protected table.

  • Grant the database role to the share containing the protected table.

  • Share the database that contains the protected table to the consumer account.

When the consumer creates a database from the share, the database roles in the share are granted to the role that creates the database from the share. This allows the account role in the consumer account to meet the policy conditions that specify the database role and access the shared data.

To access the shared data protected by the policy, the consumer must specify the database containing the shared database role to make the shared database role active in the current session. In this context, making the database role active means that the database role is available in the role hierarchy of the current role for the user. If you do not specify this shared database, users in the consumer account cannot access shared data that is protected by a policy. You can specify this database using either of the following options: