bulkGrantPrivilegeToShare
Grants a privilege on all objects of a specific type within a schema to a Snowflake share. This is a bulk operation that applies the privilege to all existing objects matching the criteria.
Note: This change type does not support automatic rollback or database inspection features (snapshot, diff, diff-changelog, and generate-changelog commands).
Available attributes
Attribute | Type | Description | Required |
|---|---|---|---|
| String | Name of the share to grant the privilege to | Yes |
| String | Type of objects to grant privilege on* | Yes |
| String | Name of the catalog (database) containing the schema | No |
| String | Name of the schema containing the objects | Yes |
| String | Privilege to grant: | Yes |
* Supported types: TABLE, EXTERNAL_TABLE, ICEBERG_TABLE, DYNAMIC_TABLE
Prerequisites
Before granting bulk privileges on database objects to a share, you must first grant USAGE privilege on the database:
GRANT USAGE ON DATABASE database_name TO SHARE share_name;
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
http://www.liquibase.org/xml/ns/pro-snowflake
http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
<!-- Grant SELECT on all tables -->
<changeSet id="bulk-grant-tables" author="examples">
<pro-snowflake:bulkGrantPrivilegeToShare
shareName="MY_SHARE"
objectType="TABLE"
catalogName="MY_DATABASE"
schemaName="PUBLIC"
privilege="SELECT"/>
</changeSet>
<!-- Grant SELECT on all external tables -->
<changeSet id="bulk-grant-external-tables" author="examples">
<pro-snowflake:bulkGrantPrivilegeToShare
shareName="MY_SHARE"
objectType="EXTERNAL_TABLE"
catalogName="MY_DATABASE"
schemaName="STAGING"
privilege="SELECT"/>
</changeSet>
<!-- Grant SELECT on all dynamic tables -->
<changeSet id="bulk-grant-dynamic-tables" author="examples">
<pro-snowflake:bulkGrantPrivilegeToShare
shareName="MY_SHARE"
objectType="DYNAMIC_TABLE"
catalogName="MY_DATABASE"
schemaName="ANALYTICS"
privilege="SELECT"/>
</changeSet>
<!-- Grant EVOLVE SCHEMA on all tables -->
<changeSet id="bulk-grant-evolve-schema" author="examples">
<pro-snowflake:bulkGrantPrivilegeToShare
shareName="MY_SHARE"
objectType="TABLE"
catalogName="MY_DATABASE"
schemaName="PUBLIC"
privilege="EVOLVE SCHEMA"/>
</changeSet>
</databaseChangeLog>