GRANT OWNERSHIP
statementsupportedAccess control (grants, roles)Transfers ownership of an object or all objects of a specified type in a schema from one role to another role. Role refers to either a role or a database role. OWNERSHIP is a special type of privilege that can only be granted from one role to another role; it cannot be revoked. For more details, see Overview of Access Control. This command is a variation of GRANT <privileges> … TO ROLE.
Syntax
supportedpartialnot supportednot scored
For object types that are not an instance of a class
GRANT OWNERSHIP
{ ON {
<object_type> <object_name>
| ALL <object_type_plural> IN { DATABASE <database_name> | SCHEMA <schema_name> }
}
| ON FUTURE <object_type_plural> IN { DATABASE <database_name> | SCHEMA <schema_name> }
}
TO { ROLE <role_name> | DATABASE ROLE <database_role_name> }
[ { REVOKE | COPY } CURRENT GRANTS ]
For an instance of a class
GRANT OWNERSHIP
ON <class_name> <instance_name>
TO { ROLE <role_name> | DATABASE ROLE <database_role_name> }
[ { REVOKE | COPY } CURRENT GRANTS ]
Parameters
| Name | Required | Description |
|---|---|---|
object_name | required | Specifies the identifier for the object on which you are transferring ownership. |
object_type | required | Specifies the type of object. One of the following: AGENT AGGREGATION POLICY ALERT AUTHENTICATION POLICY COMPUTE POOL CORTEX SEARCH SERVICE DATA EXCHANGE LISTING DATA METRIC FUNCTION DATABASE DATABASE ROLE DBT PROJECT DCM PROJECT DYNAMIC TABLE EVENT TABLE EXPERIMENT EXTERNAL TABLE EXTERNAL VOLUME FAILOVER GROUP FILE FORMAT FUNCTION GATEWAY GIT REPOSITORY ICEBERG TABLE IMAGE REPOSITORY INTEGRATION JOIN POLICY MAINTENANCE POLICY MASKING POLICY MATERIALIZED VIEW MCP SERVER NETWORK POLICY NETWORK RULE NOTEBOOK ONLINE FEATURE TABLE OPENFLOW CONNECTOR OPENFLOW DEPLOYMENT OPENFLOW RUNTIME PACKAGES POLICY PASSWORD POLICY PIPE PRIVACY POLICY PROCEDURE PROJECTION POLICY REPLICATION GROUP RESOURCE MONITOR RESTRICTED SESSION SCOPE ROLE ROW ACCESS POLICY SCHEMA SEMANTIC VIEW SESSION POLICY SECRET SEQUENCE SNAPSHOT SNAPSHOT POLICY SNAPSHOT SET STAGE STORAGE LIFECYCLE POLICY STREAM TABLE TAG TASK TYPE USER VIEW WAREHOUSE WORKSPACE ZEROCOPY CONNECTOR |
object_type_plural | required | Plural form of object_type (e.g. TABLES, VIEWS). Note that bulk grants on data metric functions, masking policies, maintenance policies, and pipes are not allowed. |
role_name | required | The identifier for the role to which the object ownership is transferred. |
database_role_name | required | The identifier for the database role to which the object ownership is transferred. 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. Ownership is limited to objects in the database that contains the database role. |
[ REVOKE | COPY ] CURRENT GRANTS | optional | Specifies whether to remove or transfer all existing outbound privileges on the object when ownership is transferred to a new role: Note Outbound privileges refer to any privileges granted on the individual object whose ownership is changing. When transferring ownership of a role, current grants refers to any roles that were granted to the current role (to create a role hierarchy). If ownership of a role is transferred with the current grants copied, then the output of the SHOW GRANTS command shows the new owner as the grantor of any child roles to the current role. Default: None. Neither operation is performed on any existing outbound privileges. Note A GRANT OWNERSHIP statement fails if existing outbound privileges on the object are neither revoked nor copied.
|
Usage notes
- You cannot transfer the OWNERSHIP privilege for the following objects: APPLICATION ROLE
- CONNECTION Only the ACCOUNTADMIN role can have the OWNERSHIP privilege on a connection object.
- Instances of a class.
- Machine learning objects (that is, models, model versions, and model monitors).
- SERVICE
- SHARE
- GRANT OWNERSHIP ON FUTURE ... IN SCHEMA is not supported for every object type. The following types return an error: AUTHENTICATION POLICIES
- EXPERIMENTS
- GATEWAYS
- MAINTENANCE POLICIES
- NOTEBOOKS
- PASSWORD POLICIES
- PRIVACY POLICIES
- SNAPSHOT POLICIES
- SNAPSHOT SETS
- STREAMLITS
- SERVICES
- ON FUTURE ... IN SCHEMA is supported for TABLES, INTERACTIVE TABLES, VIEWS, MATERIALIZED VIEWS, EXTERNAL TABLES, DYNAMIC TABLES, EVENT TABLES, FILE FORMATS, FUNCTIONS, PROCEDURES, SEQUENCES, STREAMS, TASKS, STAGES, SECRETS, SEMANTIC VIEWS, NETWORK RULES, ALERTS, TYPES, AGENTS, CORTEX SEARCH SERVICES, CONTACTS, DATA METRIC FUNCTIONS, DBT PROJECTS, GIT REPOSITORIES, ICEBERG TABLES, IMAGE REPOSITORIES, MCP SERVERS, MODELS, ONLINE FEATURE TABLES, PIPES, and WORKSPACES.
- To transfer ownership of a catalog-linked database created from a Zero-Copy connector, the new owner role must have the USAGE privilege on the Zero-Copy connector.
- The GRANT OWNERSHIP statement is blocked if outbound (that is, dependent) privileges exist on the object. The object owner (or a higher role) can explicitly copy all current privileges to the new owning role (using the COPY CURRENT GRANTS option) or revoke all outbound privileges on the object before transferring ownership (using the REVOKE CURRENT GRANTS option). For role objects, if you do not specify these clauses, the GRANT OWNERSHIP statement is not blocked when transferring a role to a new owner role. The new owner role is updated. However, a SHOW GRANTS OF ROLE transferred_role command shows two rows for the transferred role being granted to the same user: In the granted_by column, the value in one row is for the grant by the original owner role.
- In the granted_by column, the value in the other row is for the grant by the new owner role.
- Snowflake prevents the GRANT OWNERSHIP … REVOKE CURRENT GRANTS command on a shared database. For details, see the Shared database (provider account) example in this topic.
- In a consumer account, you can’t transfer ownership of a database created from a share (an imported database). GRANT OWNERSHIP on an imported database fails. To give another role access, use GRANT IMPORTED PRIVILEGES. To make another role the owner, drop the database and recreate it from the share using that role. See Shared database (consumer account).
- Transferring ownership of objects that already exist affects only those objects. Objects created later are owned by the role in use when they’re created. A future ownership grant (GRANT OWNERSHIP ON FUTURE) applies to objects of that type that are created after the grant.
- Transferring ownership of objects of the following types is blocked unless additional conditions are met: Pipes: The pipe must be paused. Tasks: You must suspend the scheduled task. Snowflake suspends all tasks in the container automatically if all tasks in a specified database or schema are transferred to another role. Tasks transferred to the same role using the COPY CURRENT GRANTS option are also suspended automatically. For more information, see Task security.
- When future grants on the same object type are defined at both the database and schema level, the schema-level grants take precedence over the database-level grants, and the database-level grants are ignored.
- To grant ownership on a materialized view, use GRANT OWNERSHIP ON VIEW. There is no separate GRANT OWNERSHIP ON MATERIALIZED VIEW statement.
- To grant ownership on a hybrid table, use GRANT OWNERSHIP ON TABLE. There is no separate GRANT OWNERSHIP ON HYBRID TABLE statement.
- You cannot transfer the OWNERSHIP privilege on a share, nor can you transfer the OWNERSHIP privilege on a connection. Only the ACCOUNTADMIN role can own the connection.
- For granting the OWNERSHIP privilege on dynamic tables, ensure the receiving role has the USAGE privilege on the database and schema that contains the dynamic table, and on the warehouse used to refresh the table. Otherwise, subsequent scheduled refreshes fail.
- For granting the OWNERSHIP privilege on future dynamic tables: If the dynamic table is set to initialize on creation (that is, INITIALIZE = ON_CREATE), ensure the new role has sufficient privileges on referenced objects. Otherwise, the initial refresh fails and results in an error stating that the object cannot be found.
- If the dynamic table is set to initialize on schedule (that is, INITIALIZE = ON_SCHEDULE), ensure the new role has sufficient privileges on referenced objects. Otherwise, the subsequent scheduled refreshes fail.
- When you transfer ownership of an Apache Iceberg™ table to a different role, Snowflake doesn’t transfer the OWNERSHIP privilege on the external volume (and catalog integration if the table is externally managed) associated with the table. To give the target role full control over the table and its related objects, you must grant the OWNERSHIP privilege on the external volume and catalog integration to the role.
- After the ownership of a notebook is transferred to a new role, the original owner role loses all access to the notebook.
- When you transfer ownership of a listing with REVOKE CURRENT GRANTS, Snowflake revokes all existing grants on that listing. The new owner must grant those privileges again. If the listing already has outbound grants, specify REVOKE CURRENT GRANTS or COPY CURRENT GRANTS. Otherwise the statement fails. For more information, see OWNERSHIP privilege on a listing.
- Database roles: Ownership can only be transferred on objects in the same database as the database role.
- Transferring ownership on an external table or its parent database blocks automatic refreshes of the table metadata by setting the AUTO_REFRESH property to FALSE. To reset the property after you transfer ownership, use the ALTER EXTERNAL TABLE command.