GRANT OWNERSHIP

statementsupportedAccess control (grants, roles)

docs.snowflake.com ↗

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

NameRequiredDescription
object_namerequiredSpecifies the identifier for the object on which you are transferring ownership.
object_typerequiredSpecifies 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_pluralrequiredPlural 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_namerequiredThe identifier for the role to which the object ownership is transferred.
database_role_namerequiredThe 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 GRANTSoptionalSpecifies 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.
  • REVOKE — Enforces RESTRICT semantics, which require removing all outbound privileges on an object before transferring ownership to a new role. This is intended to protect the new owning role from unknowingly inheriting the object with privileges already granted on it. After transferring ownership, the privileges for the object must be explicitly re-granted on the role. Note that the REVOKE keyword does not work when granting ownership of future objects of a specified type in a database or schema to a role (using GRANT OWNERSHIP ON FUTURE <object_type>).
  • COPY — Transfers ownership of an object along with a copy of any existing outbound privileges on the object. After the transfer, the new owner is identified in the system as the grantor of the copied outbound privileges (that is, in the SHOW GRANTS output for the object, the new owner is listed in the GRANTED_BY column for all privileges). As a result, any privileges that were subsequently re-granted before the change in ownership are no longer dependent on the original grantor role. Revoking a privilege using REVOKE <privileges> … FROM ROLE with the CASCADE option does not recursively revoke these formerly dependent grants. The grants must be explicitly revoked. The COPY parameter requires at least one of the following: An active role has the MANAGE GRANTS privilege on the account. An active role is the new owner (or a higher) role. The system role PUBLIC is naturally captured by this requirement because PUBLIC is granted to every role. The active role considers both primary and secondary roles. For more information, see Active roles.

Usage notes

See also

Referenced by