Jaa


Create catalogs

This article shows how to create catalogs in Unity Catalog. A catalog contains schemas (databases), and a schema contains tables, views, volumes, models, and functions.

To learn more about catalogs, see What are catalogs in Azure Databricks?.

Note

To learn how to create a foreign catalog, a Unity Catalog object that mirrors a database in an external data system, see Create a foreign catalog. See also Manage and work with foreign catalogs.

Requirements

To create a catalog, regardless of catalog type:

  • You must be an Azure Databricks metastore admin or have the CREATE CATALOG privilege on the metastore.
  • The compute resource that you use to run a notebook to create a catalog must be on Databricks Runtime 11.3 or above and must use a Unity Catalog-compliant access mode. See Access modes. SQL warehouses always support Unity Catalog.

To create a shared catalog:

  • The Delta Sharing share must already exist in your workspace. See How do I make shared data available to my team?.
  • You must be a metastore admin, have the USE PROVIDER privilege on the metastore, or own the provider object that includes the share.

To create a standard catalog:

  • If you specify a managed storage location for the catalog, you must have the CREATE MANAGED STORAGE privilege on the target external location.
  • If no metastore-level managed storage exists, then you must specify a managed storage location for the catalog.

To create a foreign catalog:

  • You must be either the owner of the connection that you use to create the foreign catalog or have the CREATE FOREIGN CATALOG privilege on the connection.
  • You must use compute on Databricks Runtime 13.1 or above. SQL warehouses must be Pro or Serverless.

Create a catalog

To create a catalog, you can use Catalog Explorer, a SQL command, the REST API, the Databricks CLI, or Terraform. When you create a catalog, two schemas (databases) are automatically created: default and information_schema.

Catalog Explorer

  1. Log in to a workspace that is linked to the metastore.

  2. Click Catalog icon Catalog.

  3. Click the Create Catalog button.

  4. On the Create a new catalog dialog, enter a Catalog name and select the catalog Type that you want to create:

    • Standard catalog: a securable object that organizes data and AI assets that are managed by Unity Catalog. For all use cases except Lakehouse Federation and catalogs created from Delta Sharing shares.
    • Foreign catalog: a securable object that mirrors a database in an external data system using Lakehouse Federation. See Overview of Lakehouse Federation setup.
    • Shared catalog: a securable object that organizes data and other assets that are shared with you as a Delta Sharing share. Creating a catalog from a share makes those assets available for users in your workspace to read. See What is a share?.
  5. Depending on the catalog type, specify the following options:

    • For standard catalogs: It is optional but strongly recommended that you specify a managed Storage location. You must have the CREATE MANAGED STORAGE privilege on the target external location that you use as a managed storage location. See Specify a managed storage location in Unity Catalog.

      You can optionally specify a subpath of a defined external location. If you don’t have an external location defined, you can create one by clicking Create a new external location.

      Important

      If your workspace does not have a metastore-level storage location, you must specify a managed storage location when you create a catalog.

    • For foreign catalogs: You must select a Connection, which is a securable object in Unity Catalog that specifies a path and credentials for accessing an external database system. See Overview of Lakehouse Federation setup.

      When you’ve selected the connection, enter the name of the Database or other Databricks Catalog that you want to mirror.

      Requirements differ depending on the data source:

      • MySQL uses a two-layer namespace and therefore does not require a database name.
      • For connections to a catalog in another Databricks workspace, enter the Databricks Catalog name instead of a database name.

      If you don’t have a connection defined, you can create one by clicking Create a new connection.

    • For shared catalogs: You must select a Provider and a Share. Once you have selected the provider, you can select one of the provider’s shares.

      If you aren’t sure which provider and share you want, you might find it easier to browse or search for providers and shares using the Catalog Explorer browser. See View providers and View shares that a provider has shared with you.

  6. Click Create.

  7. On the Catalog created! dialog, click View catalog to accept the catalog as automatically configured, or click Configure catalog (recommended) to configure catalog permissions, workspace bindings, and metadata.

    If you click View catalog, the catalog will be accessible to all workspaces attached to the metastore, and the BROWSE privilege will be granted to all account users. You can skip the rest of the steps in this procedure and proceed to adding schemas to the catalog. See Create schemas.

    You can return to the catalog details page in Catalog Explorer at any time to update the owner, tags, comments, workspace bindings, permissions, and schemas.

  8. On the Configure catalog > Workspaces page, specify the workspace that the catalog is bound to.

    By default, the catalog is shared with all workspaces attached to the current metastore. If the catalog will contain data that should be restricted to specific workspaces, clear the All workspace have access option and use the Assign to workspaces button to add those workspaces. The current workspace must be included.

    After you assign a workspace, you can optionally change its default Read & Write access level to Read Only: select the workspace from the list and click the Manage Access Level button.

    For more information, see Limit catalog access to specific workspaces.

  9. Click Next to assign Permissions for your catalog.

    All account users have the BROWSE privilege by default, giving them the ability to discover catalog metadata without having read access to the data.

    To grant a privilege to a user, group, or service principal, click Grant and follow the instructions in Unity Catalog privileges and securable objects.

  10. Click Next to add optional tag and comment Metadata.

    Tags are key-value pairs that you can use to organize and categorize catalogs to simplify search and discovery of your data assets. Values are optional. See Apply tags to Unity Catalog securable objects.

    A Comment is an open-ended field that is often used to provide a description to help users discover the data assets in the catalog. See Add comments to data and AI assets.

  11. Click Save.

  12. Add schemas and data objects to the catalog.

    See Create schemas.

You can use Catalog Explorer to update the owner, tags, comments, workspace bindings, and permissions any time after you have created the catalog.

SQL

To create a standard catalog, run the following SQL command in a notebook or SQL query editor. Items in brackets are optional. Replace the placeholder values:

  • <catalog-name>: A name for the catalog.

  • <location-path>: Optional but strongly recommended. Provide a storage location path if you want managed tables in this catalog to be stored in a location that is different than the default root storage configured for the metastore.

    Important

    If your workspace does not have a metastore-level storage location, you must specify a managed storage location when you create a catalog.

    This path must be defined in an external location configuration, and you must have the CREATE MANAGED STORAGE privilege on the external location configuration. You can use the path that is defined in the external location configuration or a subpath (in other words, 'abfss://my-container-name@storage-account-name.dfs.core.windows.net/finance' or 'abfss://my-container-name@storage-account-name.dfs.core.windows.net/finance/product').

  • <comment>: Optional description or other comment.

CREATE CATALOG [ IF NOT EXISTS ] <catalog-name>
   [ MANAGED LOCATION '<location-path>' ]
   [ COMMENT <comment> ];

For example, to create a catalog named example:

CREATE CATALOG IF NOT EXISTS example;

To create a shared catalog, run the following command in a notebook or SQL query editor. Items in brackets are optional.

CREATE CATALOG [IF NOT EXISTS] <catalog-name>
USING SHARE <provider-name>.<share-name>;
[ COMMENT <comment> ];

To create a foreign catalog, run the following command in a notebook or SQL query editor. Items in brackets are optional. Replace the placeholder values:

  • <catalog-name>: Name for the catalog in Azure Databricks.
  • <connection-name>: The connection object that specifies the data source, path, and access credentials.
  • <database-name>: Name of the database you want to mirror as a catalog in Azure Databricks. Not required for MySQL, which uses a two-layer namespace. For Databricks-to-Databricks Lakehouse Federation, use catalog '<external-catalog-name>' instead.
  • <external-catalog-name>: Databricks-to-Databricks only: Name of the catalog in the external Databricks workspace that you are mirroring. See Run federated queries on another Databricks workspace.
CREATE FOREIGN CATALOG [IF NOT EXISTS] <catalog-name> USING CONNECTION <connection-name>
OPTIONS [(database '<database-name>') | (catalog '<external-catalog-name>')];

See also Create a foreign catalog.

To limit catalog access to specific workspaces in your account, also known as workspace-catalog binding, see Limit catalog access to specific workspaces.

For detailed parameter descriptions, see CREATE CATALOG.

After you’ve created the catalog, assign privileges to the catalog. See Unity Catalog privileges and securable objects.

Other

Terraform: You can create a catalog using the Databricks Terraform provider and databricks_catalog. You can retrieve information about catalogs using databricks_catalogs.

REST API: Use POST /api/2.1/unity-catalog/catalogs.

Databricks CLI: databricks catalogs create <catalog-name> [options] For a list of options, run databricks catalogs create -h. Options are also described in the API reference. Follow the API link in the preceding paragraph.

After you’ve created the catalog, assign privileges to the catalog. See Unity Catalog privileges and securable objects.

More information