GRANT <PRIVILEGE>
statementnot supportedAccess control (grants, roles)Grants access privileges for databases and other supported database objects (schemas, UDFs, tables, views, and models) to a share. Granting privileges on these objects effectively adds the objects to the share, which can then be shared with one or more consumer accounts. For more details, see About Secure Data Sharing and Create and configure shares.
Syntax
GRANT objectPrivilege ON
{ DATABASE <name>
| SCHEMA <name>
| FUNCTION <name>
| MODEL <name>
| SEMANTIC VIEW <name>
| { TABLE <name> | ALL TABLES IN SCHEMA <schema_name> }
| { EXTERNAL TABLE <name> | ALL EXTERNAL TABLES IN SCHEMA <schema_name> }
| { ICEBERG TABLE <name> | ALL ICEBERG TABLES IN SCHEMA <schema_name> }
| { DYNAMIC TABLE <name> | ALL DYNAMIC TABLES IN SCHEMA <schema_name> }
| TAG <name>
| VIEW <name> }
TO SHARE <share_name>
Where
objectPrivilege ::=
-- For DATABASE
REFERENCE_USAGE [ , ... ]
-- For DATABASE, FUNCTION, MODEL, or SCHEMA
USAGE [ , ... ]
-- For MODEL or TAG
READ
-- For SEMANTIC VIEW
{ REFERENCES | SELECT } [ , ... ]
-- For TABLE
EVOLVE SCHEMA [ , ... ]
-- For EXTERNAL TABLE, ICEBERG TABLE, TABLE, or VIEW
SELECT [ , ... ]
Parameters
| Name | Required | Description |
|---|---|---|
name | Specifies the identifier for the object for which the specified privilege is granted. | |
schema_name | Specifies the identifier for the schema for which the specified privilege is granted for all tables. | |
share_name | Specifies the identifier for the share from which the specified privilege is granted. |
Usage notes
- The USAGE privilege on only a single database can be granted to a share; however, within that database, privileges on multiple schemas, UDFs, tables, views, and models can be granted to the share.
- Privileges on individual objects must be granted to a share in separate GRANT statements. The only exceptions are the SELECT privilege on tables (including Apache Iceberg™ tables) and views. Using an ALL clause, you can grant SELECT on all tables in a specified schema to a share. You can also grant SELECT on all views in a specified schema to a share if the share has SECURE_OBJECTS_ONLY=FALSE.
- By default, the SELECT privilege on views can only be granted on secure views. To share non-secure views, see Share data in non-secured views.
- The USAGE privilege can only be granted on secure UDFs. Attempting to grant the USAGE privilege on a non-secure UDF to a share returns an error.
- Currently, sharing a UDF that references an object from another database is not supported. For example, if you attempt to grant USAGE on a UDF that references a secure view from another database, an error is returned.
- For models, the privilege you grant determines what consumers can do with the shared model: USAGE lets consumers run inference with the model on a warehouse. Consumers cannot access the model’s code, weights, or other artifacts.
- READ lets consumers deploy the model to Snowpark Container Services for inference and view the model’s metadata, such as comments, tags, and metrics.
- For more details, see Sharing models.
- Use the REFERENCE_USAGE privilege when sharing a secure view that references objects belonging to multiple databases, as follows: The REFERENCE_USAGE privilege must be granted individually on each database.
- The REFERENCE_USAGE privilege must be granted on a database before granting the SELECT privilege on a secure view to a share.
- Grant the USAGE privilege on a database (typically the database that contains the shared secure view) to the share before you grant REFERENCE_USAGE on any database. Otherwise, Snowflake returns the following error: Cannot grant REFERENCE_USAGE on database <db_name> to share <share_name>. Grant USAGE on a database to share prior to granting REFERENCE_USAGE. For more information, see Access control: Disallow GRANT REFERENCE_USAGE if GRANT USAGE isn’t set first.
- For more details, see Share data from multiple databases.
- Secure Data Sharing: Data providers cannot add new objects to a share automatically using future grants. That is, data providers cannot grant privileges on future objects to a share using GRANT <privilege> … TO SHARE statements.
- You cannot reshare a database or database objects created from a share. If you attempt to grant the USAGE privilege on a database or database objects created from a share to a different share, an error is returned.
- If you specify a TABLE object that is an Iceberg table, the command grants the privilege on that Iceberg table.