A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/sql/grant-privilege below:

Website Navigation


GRANT <privileges> … TO ROLE

GRANT <privileges> … TO ROLE

Grants one or more access privileges on a securable object to a role or database role. The privileges that can be granted are object-specific.

For information on granting privileges on securable objects to a share, see GRANT <privilege> … TO SHARE.

Roles:

The privileges that can be granted to roles are grouped into the following categories:

Database roles:

The privileges that can be granted to database roles are grouped into the following categories:

For more details about roles and securable objects, see Overview of Access Control.

Variations:

GRANT OWNERSHIP , GRANT <privilege> … TO SHARE

See also:

REVOKE <privileges> … FROM ROLE

Syntax

Account roles:

GRANT {  { globalPrivileges         | ALL [ PRIVILEGES ] } ON ACCOUNT
       | { accountObjectPrivileges  | ALL [ PRIVILEGES ] } ON { USER | RESOURCE MONITOR | WAREHOUSE | COMPUTE POOL | DATABASE | INTEGRATION | CONNECTION | FAILOVER GROUP | REPLICATION GROUP | EXTERNAL VOLUME } <object_name>
       | { schemaPrivileges         | ALL [ PRIVILEGES ] } ON { SCHEMA <schema_name> | ALL SCHEMAS IN DATABASE <db_name> }
       | { schemaPrivileges         | ALL [ PRIVILEGES ] } ON { FUTURE SCHEMAS IN DATABASE <db_name> }
       | { schemaObjectPrivileges   | ALL [ PRIVILEGES ] } ON { <object_type> <object_name> | ALL <object_type_plural> IN { DATABASE <db_name> | SCHEMA <schema_name> } }
       | { schemaObjectPrivileges   | ALL [ PRIVILEGES ] } ON FUTURE <object_type_plural> IN { DATABASE <db_name> | SCHEMA <schema_name> }
      }
  TO [ ROLE ] <role_name> [ WITH GRANT OPTION ]

Copy

Database roles:

GRANT {  { CREATE SCHEMA | MODIFY | MONITOR | USAGE } [ , ... ] } ON DATABASE <object_name>
       | { schemaPrivileges         | ALL [ PRIVILEGES ] } ON { SCHEMA <schema_name> | ALL SCHEMAS IN DATABASE <db_name> }
       | { schemaPrivileges         | ALL [ PRIVILEGES ] } ON { FUTURE SCHEMAS IN DATABASE <db_name> }
       | { schemaObjectPrivileges   | ALL [ PRIVILEGES ] } ON { <object_type> <object_name> | ALL <object_type_plural> IN { DATABASE <db_name> | SCHEMA <schema_name> } }
       | { schemaObjectPrivileges   | ALL [ PRIVILEGES ] } ON FUTURE <object_type_plural> IN { DATABASE <db_name> | SCHEMA <schema_name> }
      }
  TO DATABASE ROLE <database_role_name> [ WITH GRANT OPTION ]

Copy

Where:

globalPrivileges ::=
  {
      CREATE {
          ACCOUNT | APPLICATION | APPLICATION PACKAGE | COMPUTE POOL | LISTING
          | DATABASE | EXTERNAL VOLUME | FAILOVER GROUP | INTEGRATION | NETWORK POLICY
          | ORGANIZATION LISTING | ORGANIZATION PROFILE | REPLICATION GROUP | ROLE | SHARE
       | USER | WAREHOUSE
      }
      | ATTACH POLICY | AUDIT | BIND SERVICE ENDPOINT
      | APPLY {
         { AGGREGATION | AUTHENTICATION | JOIN | MASKING | PACKAGES | PASSWORD
           | PROJECTION | ROW ACCESS | SESSION } POLICY
         | CONTACT
         | TAG }
      | EXECUTE { ALERT | DATA METRIC FUNCTION | MANAGED ALERT | MANAGED TASK | TASK }
      | IMPORT { SHARE | ORGANIZATION LISTING }
      | MANAGE { ACCOUNT SUPPORT CASES | EVENT SHARING | GRANTS | LISTING AUTO FULFILLMENT | ORGANIZATION SUPPORT CASES | SHARE TARGET | USER SUPPORT CASES | WAREHOUSES }
      | MODIFY { LOG LEVEL | TRACE LEVEL | SESSION LOG LEVEL | SESSION TRACE LEVEL }
      | MONITOR { EXECUTION | SECURITY | USAGE }
      | OVERRIDE SHARE RESTRICTIONS | PURCHASE DATA EXCHANGE LISTING | RESOLVE ALL
      | READ SESSION
  }
  [ , ... ]

Copy

accountObjectPrivileges ::=
-- For APPLICATION PACKAGE
    { ATTACH LISTING | DEVELOP | INSTALL | MANAGE VERSIONS | MANAGE RELEASES } [ , ... ]
-- For COMPUTE POOL
   { MODIFY | MONITOR | OPERATE | USAGE } [ , ... ]
-- For CONNECTION
   { FAILOVER } [ , ... ]
-- For DATABASE
   { APPLYBUDGET | CREATE { DATABASE ROLE | SCHEMA }
   | IMPORTED PRIVILEGES | MODIFY | MONITOR | USAGE } [ , ... ]
-- For EXTERNAL VOLUME
   { USAGE } [ , ... ]
-- For FAILOVER GROUP
   { FAILOVER | MODIFY | MONITOR | REPLICATE } [ , ... ]
-- For INTEGRATION
   { USAGE | USE_ANY_ROLE } [ , ... ]
-- For ORGANIZATION PROFILE
   { MODIFY } [ , ... ]
-- For REPLICATION GROUP
   { MODIFY | MONITOR | REPLICATE } [ , ... ]
-- For RESOURCE MONITOR
   { MODIFY | MONITOR } [ , ... ]
-- For USER
   { IMPERSONATE | MODIFY PROGRAMMATIC AUTHENTICATION METHODS | MONITOR } [ , ... ]
-- For WAREHOUSE
   { APPLYBUDGET | MODIFY | MONITOR | USAGE | OPERATE } [ , ... ]

Copy

schemaPrivileges ::=

    ADD SEARCH OPTIMIZATION | APPLYBUDGET
  | CREATE {
       AGENT | ALERT | CONTACT | CORTEX SEARCH SERVICE | DATA METRIC FUNCTION | DATASET
      | DBT PROJECT | EVENT TABLE | FILE FORMAT | FUNCTION
      | { GIT | IMAGE } REPOSITORY
      | MODEL | NETWORK RULE | NOTEBOOK | PIPE | PROCEDURE
      | { AGGREGATION | AUTHENTICATION | MASKING | PACKAGES
         | PASSWORD | PRIVACY | PROJECTION | ROW ACCESS | SESSION } POLICY
      | SECRET | SEQUENCE | SERVICE | SNAPSHOT | STAGE | STREAM | STREAMLIT
      | SNOWFLAKE.CORE.BUDGET
      | SNOWFLAKE.DATA_PRIVACY.CLASSIFICATION_PROFILE
      | SNOWFLAKE.DATA_PRIVACY.CUSTOM_CLASSIFIER
      | SNOWFLAKE.ML.ANOMALY_DETECTION | SNOWFLAKE.ML.CLASSIFICATION
         | SNOWFLAKE.ML.FORECAST | SNOWFLAKE.ML.TOP_INSIGHTS
      | SNOWFLAKE.ML.DOCUMENT_INTELLIGENCE
      | [ { DYNAMIC | EXTERNAL | ICEBERG } ] TABLE
      | TAG | TASK | [ { MATERIALIZED | SEMANTIC } ] VIEW
      }
   | MODIFY | MONITOR | USAGE
   [ , ... ]

Copy

schemaObjectPrivileges ::=
  -- For ALERT
     { MONITOR | OPERATE } [ , ... ]
  -- For CONTACT
     { APPLY | MODIFY } [ , ... ]
  -- For DATA METRIC FUNCTION
     USAGE [ , ... ]
  -- For DATASET, FILE FORMAT, FUNCTION (UDF or external function), MODEL, PROCEDURE, SECRET, SEQUENCE, or SNAPSHOT
     USAGE [ , ... ]
  -- For DBT PROJECT
     USAGE [ , ... ]
  -- For DYNAMIC TABLE
     MONITOR, OPERATE, SELECT [ , ...]
  -- For EVENT TABLE
     { APPLYBUDGET | DELETE | OWNERSHIP | REFERENCES | SELECT | TRUNCATE } [ , ... ]
  -- For GIT REPOSITORY
     { READ, WRITE } [ , ... ]
  -- For HYBRID TABLE
     { APPLYBUDGET | DELETE | INSERT | REFERENCES | SELECT | TRUNCATE | UPDATE } [ , ... ]
  -- For IMAGE REPOSITORY
     { READ, WRITE } [ , ... ]
  -- For ICEBERG TABLE
     { APPLYBUDGET | DELETE | INSERT | REFERENCES | SELECT | TRUNCATE | UPDATE } [ , ... ]
  -- For MATERIALIZED VIEW
     { APPLYBUDGET | REFERENCES | SELECT } [ , ... ]
  -- For PIPE
     { APPLYBUDGET | MONITOR | OPERATE } [ , ... ]
  -- For { AGGREGATION | AUTHENTICATION | MASKING | JOIN | PACKAGES | PASSWORD | PRIVACY | PROJECTION | ROW ACCESS | SESSION } POLICY or TAG
     APPLY [ , ... ]
  -- For SECRET
     { READ | USAGE } [ , ... ]
  -- For SEMANTIC VIEW
     { SELECT | REFERENCES } [ , ... ]
  -- For SERVICE
     { MONITOR | OPERATE } [ , ... ]
  -- For external STAGE
     USAGE [ , ... ]
  -- For internal STAGE
     READ [ , WRITE ] [ , ... ]
  -- For STREAM
     SELECT [ , ... ]
  -- For STREAMLIT
     USAGE [ , ... ]
  -- For TABLE
     { APPLYBUDGET | DELETE | EVOLVE SCHEMA | INSERT | REFERENCES | SELECT | TRUNCATE | UPDATE } [ , ... ]
  -- For TAG
     READ
  -- For TASK
     { APPLYBUDGET | MONITOR | OPERATE } [ , ... ]
  -- For VIEW
     { REFERENCES | SELECT } [ , ... ]

Copy

For more details about the privileges supported for each object type, see Access control privileges.

Required parameters
object_name

Specifies the identifier for the object on which the privileges are granted.

object_type

Specifies the type of object for schema-level objects.

object_type_plural

Plural form of object_type (for example, TABLES, VIEWS).

Note that bulk grants on pipes are not allowed.

role_name

Specifies the identifier for the recipient role (that is, the role to which the privileges are granted).

database_role_name

Specifies the identifier for the recipient database role (that is, the role to which the privileges are granted). If the identifier is not fully qualified in the form of db_name.database_role_name, the command looks for the database role in the current database for the session.

All privileges are limited to the database that contains the database role, as well as other objects in the same database.

Optional parameters
FUTURE

Specifies that privileges are granted on new (that is, future) database or schema objects of a specified type (such as tables or views) rather than on existing objects. Note that future grants can be revoked at any time using REVOKE <privileges> … FROM ROLE with the ON FUTURE parameter; any privileges granted on existing objects are retained. For more information about future grants, see Future grants on database or schema objects in this topic.

WITH GRANT OPTION

If specified, allows the recipient role to grant the privileges to other roles.

Default: No value, which means the recipient role cannot grant the privileges to other roles.

Usage notes Access control requirements
Granting privileges on individual objects:

In general, a role with any one of the following sets of privileges can grant privileges on an object to other roles:

In managed access schemas (that is, schemas created using the CREATE SCHEMA … WITH MANAGED ACCESS syntax), object owners lose the ability to make grant decisions. Only the schema owner (that is, the role with the OWNERSHIP privilege on the schema) or a role with the global MANAGE GRANTS privilege can grant privileges on objects in the schema.

Note that a role that holds the global MANAGE GRANTS privilege can grant additional privileges to the current (grantor) role.

Defining grants on future objects of a specified type:

Database level

The global MANAGE GRANTS privilege is required to grant privileges on future objects in a database. Only the SECURITYADMIN and ACCOUNTADMIN system roles have the MANAGE GRANTS privilege; however, the privilege can be granted to custom roles.

Schema level

In managed access schemas (that is, schemas created using the CREATE SCHEMA … WITH MANAGED ACCESS syntax), either the schema owner (that is, the role with the OWNERSHIP privilege on the schema) or a role with the global MANAGE GRANTS privilege can grant privileges on future objects in the schema.

In standard schemas, the global MANAGE GRANTS privilege is required to grant privileges on future objects in the schema.

For more information about defining grants on future objects of a specified type, see Future grants on database or schema objects (in this topic).

Future grants on database or schema objects

The notes in this section apply when assigning future grants on objects in a schema or a database; that is, when using the ON FUTURE parameter.

For more information, see managed access schemas.

Considerations Restrictions and limitations Examples Roles

Grant the necessary privileges to operate (that is, suspend or resume) the report_wh warehouse to the analyst role:

GRANT OPERATE ON WAREHOUSE report_wh TO ROLE analyst;

Copy

Repeat the previous example, but also allow the analyst role to grant the privilege to other roles:

GRANT OPERATE ON WAREHOUSE report_wh TO ROLE analyst WITH GRANT OPTION;

Copy

Grant the SELECT privilege on all existing tables in the mydb.myschema schema to the analyst role:

GRANT SELECT ON ALL TABLES IN SCHEMA mydb.myschema to ROLE analyst;

Copy

Grant all privileges on two UDFs in the mydb.myschema schema to the analyst role:

GRANT ALL PRIVILEGES ON FUNCTION mydb.myschema.add5(number) TO ROLE analyst;

GRANT ALL PRIVILEGES ON FUNCTION mydb.myschema.add5(string) TO ROLE analyst;

Copy

Note that the UDFs have different arguments, which is how Snowflake uniquely identifies UDFs with the same name. For more details about UDF naming, see User-defined functions overview.

Grant USAGE privilege on a stored procedure in the mydb.myschema schema to the analyst role:

GRANT USAGE ON PROCEDURE mydb.myschema.myprocedure(number) TO ROLE analyst;

Copy

Note that stored procedure names (like UDF names) can be overloaded, so you must specify the data type of the arguments(s). For more details about name overloading, see Overloading procedures and functions.

Grant the CREATE PROVISIONED THROUGHPUT privilege to a role:

GRANT CREATE PROVISIONED THROUGHPUT ON ACCOUNT TO ROLE myrole;

Copy

Grant the privilege to create materialized views in the specified schema:

GRANT CREATE MATERIALIZED VIEW ON SCHEMA mydb.myschema TO ROLE myrole;

Copy

Grant the SELECT and INSERT privileges on all future tables created in the mydb.myschema schema to the role1 role:

GRANT SELECT, INSERT ON FUTURE TABLES IN SCHEMA mydb.myschema TO ROLE role1;

Copy

Grant the USAGE privilege on all future schemas in the mydb database to the role1 role:

USE ROLE ACCOUNTADMIN;

GRANT USAGE ON FUTURE SCHEMAS IN DATABASE mydb TO ROLE role1;

Copy

Grant ALL PRIVILEGES on all tables in a given schema to a given role. Note that this grant applies to both standard tables and hybrid tables in the specified schema:

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA ht_schema TO ROLE ht_role;

Copy

Database roles

Grant the SELECT privilege on all existing tables in the mydb.myschema schema to the mydb.dr1 database role:

GRANT SELECT ON ALL TABLES IN SCHEMA mydb.myschema
  TO DATABASE ROLE mydb.dr1;

Copy

Grant all privileges on two UDFs in the mydb.myschema schema to the mydb.dr1 database role:

GRANT ALL PRIVILEGES ON FUNCTION mydb.myschema.add5(number)
  TO DATABASE ROLE mydb.dr1;

GRANT ALL PRIVILEGES ON FUNCTION mydb.myschema.add5(string)
  TO DATABASE ROLE mydb.dr1;

Copy

Note that the UDFs have different arguments, which is how Snowflake uniquely identifies UDFs with the same name. For more details about UDF naming, see User-defined functions overview.

Grant usage privilege on a stored procedure in the mydb.myschema schema to the mydb.dr1 database role:

GRANT USAGE ON PROCEDURE mydb.myschema.myprocedure(number)
  TO DATABASE ROLE mydb.dr1;

Copy

Note that stored procedure names (like UDF names) can be overloaded, so you must specify the data type of the arguments(s). For more details about overloading stored procedures, see Overloading procedures and functions.

Grant the privilege to create materialized views in the specified schema to the mydb.dr1 database role:

GRANT CREATE MATERIALIZED VIEW ON SCHEMA mydb.myschema
  TO DATABASE ROLE mydb.dr1;

Copy

Grant the SELECT and INSERT privileges on all future tables created in the mydb.myschema schema to the mydb.dr1 database role:

GRANT SELECT,INSERT ON FUTURE TABLES IN SCHEMA mydb.myschema
  TO DATABASE ROLE mydb.dr1;

Copy

Grant the USAGE privilege on all future schemas in the mydb database to the role1 role:

USE ROLE ACCOUNTADMIN;

GRANT USAGE ON FUTURE SCHEMAS IN DATABASE mydb
  TO DATABASE ROLE mydb.dr1;

Copy

Classes

To allow an account role to create budgets in a schema, grant the CREATE SNOWFLAKE.CORE.BUDGET privilege on the schema to the role:

USE ROLE ACCOUNTADMIN;

GRANT CREATE SNOWFLAKE.CORE.BUDGET ON SCHEMA budgets_db.budgets_schema
  TO ROLE budget_admin;

Copy

To allow an account role to create an ML Function model or instance (forecast, anomaly detection, or classification) in a schema, grant the appropriate privilege on the schema to the role. The following privileges are available.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4