Search code examples
viewsnowflake-cloud-data-platformshareuser-permissions

multiple db reference_usage permission at once snowflake


I am working on a secure view and share in snowflake. So, I need to grant reference_usage of each DB to share before granting view permission to share.

My view has like 7-8 databases in its statement(due to joining) and so I need to grant all these DB reference usage permission to share.

One way of doing this, I can run the below command for each database.

grant reference_usage on database db_XYZ to share share_ABC;

Is there any command in snowflake to grant permission to all databases at once?


Solution

  • No, the REFERENCE_USAGE privilege must be granted individually to each database.

    https://docs.snowflake.com/en/sql-reference/sql/grant-privilege-share.html#usage-notes

    Of course, you can write a script to generate and execute grant commands for all databases.