Manage privileges in Unity Catalog

This article explains how to control access to data and other objects in Unity Catalog. To learn about how this model differs from access control in the Hive metastore, see Work with Unity Catalog and the legacy Hive metastore.

Who can manage privileges?

Initially, users have no access to data in a metastore. Databricks account admins, workspace admins, and metastore admins have default privileges for managing Unity Catalog. See Admin privileges in Unity Catalog.

All securable objects in Unity Catalog have an owner. Object owners have all privileges on that object, including the ability to grant privileges to other principals. See Manage Unity Catalog object ownership.

Privileges can be granted by either a metastore admin, the owner of an object, or the owner of the catalog or schema that contains the object. Account admins can also grant privileges directly on a metastore.

Workspace catalog privileges

If your workspace was enabled for Unity Catalog automatically, the workspace is attached to a metastore by default and a workspace catalog is created for your workspace in the metastore. Workspace admins are the default owners of the workspace catalog. As owners, they can manage privileges on the workspace catalog and all child objects.

All workspace users receive the USE CATALOG privilege on the workspace catalog. Workspace users also receive the USE SCHEMA, CREATE TABLE, CREATE VOLUME, CREATE MODEL, and CREATE FUNCTION privileges on the default schema in the catalog.

For more information, see Automatic enablement of Unity Catalog.

Inheritance model

Securable objects in Unity Catalog are hierarchical, and privileges are inherited downward. The highest level object that privileges are inherited from is the catalog. This means that granting a privilege on a catalog or schema automatically grants the privilege to all current and future objects within the catalog or schema. For example, if you give a user the SELECT privilege on a catalog, then that user will be able to select (read) all tables and views in that catalog. Privileges that are granted on a Unity Catalog metastore are not inherited.

Unity Catalog object hierarchy

Owners of an object are automatically granted all privileges on that object. In addition, object owners can grant privileges on the object itself and on all of its child objects. This means that owners of a schema do not automatically have all privileges on the tables in the schema, but they can grant themselves privileges on the tables in the schema.

Show, grant, and revoke privileges

You can manage privileges for metastore objects using SQL commands, the Databricks CLI, the Databricks Terraform provider, or Catalog Explorer.

In the SQL commands that follow, replace these placeholder values:

  • <privilege-type> is a Unity Catalog privilege type. See Privilege types.

  • <securable-type>: The type of securable object, such as CATALOG or TABLE. See Securable objects

  • <securable-name>: The name of the securable. If the securable type is METASTORE, do not provide the securable name. It is assumed to be the metastore attached to the workspace.

  • <principal> is a user, service principal (represented by its applicationId value), or group. You must enclose users, service principals, and group names that include special characters in backticks ( ` ` ). See Principal.

Show grants on objects in a Unity Catalog metastore

Permissions required: Metastore admin, the owner of the object, the owner of the catalog or schema that contains the object. You can also view your own grants.

  1. In your Databricks workspace, click Catalog icon Catalog.

  2. Select the object, such as a catalog, schema, table, or view.

  3. Go to the Permissions tab.

Run the following SQL command in a notebook or SQL query editor. You can show grants on a specific principal, or you can show all grants on a securable object.

  SHOW GRANTS [principal] ON  <securable-type> <securable-name>

For example, the following command shows all grants on a schema named default in the parent catalog named main:

  SHOW GRANTS ON SCHEMA main.default;

The command returns:

  principal     actionType     objectType objectKey
  ------------- -------------  ---------- ------------
  finance-team   CREATE TABLE  SCHEMA     main.default
  finance-team   USE SCHEMA    SCHEMA     main.default

Grant permissions on objects in a Unity Catalog metastore

Permissions required: Metastore admin, the owner of the object, or the owner of the catalog or schema that contains the object.

  1. In your Databricks workspace, click Catalog icon Catalog.

  2. Select the object, such as a catalog, schema, table, or view.

  3. Go to the Permissions tab.

  4. Click Grant.

  5. Enter the email address for a user or the name of a group.

  6. Select the permissions to grant.

  7. Click OK.

Run the following SQL command in a notebook or SQL query editor.

  GRANT <privilege-type> ON <securable-type> <securable-name> TO <principal>

For example, the following command grants a group named finance-team access to create tables in a schema named default with the parent catalog named main:

  GRANT CREATE TABLE ON SCHEMA main.default TO `finance-team`;
  GRANT USE SCHEMA ON SCHEMA main.default TO `finance-team`;
  GRANT USE CATALOG ON CATALOG main TO `finance-team`;

Revoke permissions on objects in a Unity Catalog metastore

Permissions required: Metastore admin, the owner of the object, or the owner of the catalog or schema that contains the object.

  1. In your Databricks workspace, click Catalog icon Catalog.

  2. Select the object, such as a catalog, schema, table, or view.

  3. Go to the Permissions tab.

  4. Select a privilege that has been granted to a user, service principal, or group.

  5. Click Revoke.

  6. To confirm, click Revoke.

Run the following SQL command in a notebook or SQL query editor.

  REVOKE <privilege-type> ON <securable-type> <securable-name> TO <principal>

For example, the following command revokes a group named finance-team access to create tables in a schema named default with the parent catalog named main:

  REVOKE CREATE TABLE ON SCHEMA main.default TO `finance-team`;

Show grants on a metastore

Permissions required: Metastore admin or account admin. You can also view your own grants on a metastore.

  1. In your Databricks workspace, click Catalog icon Catalog.

  2. Next to the Catalog Explorer page label, click the icon next to the metastore name.

  3. Go to the Permissions tab.

Run the following SQL command in a notebook or SQL query editor. You can show grants on a specific principal, or you can show all grants on a metastore.

  SHOW GRANTS [principal] ON METASTORE

Grant permissions on a metastore

Permissions required: Metastore admin or account admin.

  1. In your Databricks workspace, click Catalog icon Catalog.

  2. Next to the Catalog Explorer page label, click the icon next to the metastore name.

  3. On the Permissions tab, click Grant.

  4. Enter the email address for a user or the name of a group.

  5. Select the permissions to grant.

  6. Click OK.

  1. Run the following SQL command in a notebook or SQL query editor.

    GRANT <privilege-type> ON METASTORE TO <principal>`;
    

    When you grant privileges on a metastore, you do not include the metastore name, because the metastore that is attached to your workspace is assumed.

Revoke permissions on a metastore

Permissions required: Metastore admin or account admin..

  1. In your Databricks workspace, click Catalog icon Catalog.

  2. Next to the Catalog Explorer page label, click the icon next to the metastore name.

  3. On the Permissions tab, select a user or group and click Revoke.

  4. To confirm, click Revoke.

  1. Run the following SQL command in a notebook or SQL query editor.

    REVOKE <privilege-type> ON METASTORE TO <principal>;
    

    When you revoke privileges on a metastore, you do not include the metastore name, because the metastore that is attached to your workspace is assumed.