Share via


metastores command group

Note

This information applies to Databricks CLI versions 0.205 and above. The Databricks CLI is in Public Preview.

Databricks CLI use is subject to the Databricks License and Databricks Privacy Notice, including any Usage Data provisions.

The metastores command group within the Databricks CLI allows you to manage metastores. A metastore is the top-level container of objects in Unity Catalog. It stores data assets (tables and views) and the permissions that govern access to them. See Metastore.

databricks metastores assign

Create a new metastore assignment. If an assignment for the same workspace_id exists, it will be overwritten by the new metastore_id and default_catalog_name. The caller must be an account admin.

databricks metastores assign WORKSPACE_ID METASTORE_ID DEFAULT_CATALOG_NAME [flags]

Arguments

WORKSPACE_ID

    A workspace ID.

METASTORE_ID

    The unique ID of the metastore.

DEFAULT_CATALOG_NAME

    Deprecated. Use "Default Namespace API" to configure the default catalog for a Databricks workspace. The name of the default catalog in the metastore.

Options

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

Global flags

Examples

The following example assigns a metastore to a workspace:

databricks metastores assign 123456789 abc123-def456-ghi789 main

databricks metastores create

Create a new metastore based on a provided name and optional storage root path. By default (if the owner field is not set), the owner of the new metastore is the user calling the createMetastore API. If the owner field is set to the empty string (""), the ownership is assigned to the System User instead.

databricks metastores create NAME [flags]

Arguments

NAME

    The user-specified name of the metastore.

Options

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

--region string

    Cloud region which the metastore serves (e.g., us-west-2, westus).

--storage-root string

    The storage root URL for metastore.

Global flags

Examples

The following example creates a metastore with a name and storage root:

databricks metastores create my-metastore --storage-root s3://my-bucket/metastore-root --region us-west-2

databricks metastores current

Get the metastore assignment for the workspace being accessed.

databricks metastores current [flags]

Options

Global flags

Examples

The following example gets the current metastore assignment:

databricks metastores current

databricks metastores delete

Delete a metastore. The caller must be a metastore admin.

databricks metastores delete ID [flags]

Arguments

ID

    Unique ID of the metastore.

Options

--force

    Force deletion even if the metastore is not empty.

Global flags

Examples

The following example deletes a metastore:

databricks metastores delete abc123-def456-ghi789

The following example forcefully deletes a metastore even if it's not empty:

databricks metastores delete abc123-def456-ghi789 --force

databricks metastores get

Get a metastore that matches the supplied ID. The caller must be a metastore admin to retrieve this info.

databricks metastores get ID [flags]

Arguments

ID

    Unique ID of the metastore.

Options

Global flags

Examples

The following example gets information about a specific metastore:

databricks metastores get abc123-def456-ghi789

databricks metastores list

List the available metastores. The caller must be an admin to retrieve this info. There is no guarantee of a specific ordering of the items in the list.

databricks metastores list [flags]

Options

--max-results int

    Maximum number of metastores to return.

--page-token string

    Opaque pagination token to go to next page based on previous query.

Global flags

Examples

The following example lists all available metastores:

databricks metastores list

The following example lists metastores with pagination:

databricks metastores list --max-results 10 --page-token abc123token

databricks metastores summary

Get summary information about a metastore. This summary includes the storage credential, the cloud vendor, the cloud region, and the global metastore ID.

databricks metastores summary [flags]

Options

Global flags

Examples

The following example gets a metastore summary:

databricks metastores summary

databricks metastores unassign

Delete a metastore assignment. The caller must be an account administrator.

databricks metastores unassign WORKSPACE_ID METASTORE_ID [flags]

Arguments

WORKSPACE_ID

    A workspace ID.

METASTORE_ID

    Query for the ID of the metastore to delete.

Options

Global flags

Examples

The following example unassigns a metastore from a workspace:

databricks metastores unassign 123456789 abc123-def456-ghi789

databricks metastores update

Update information for a specific metastore. The caller must be a metastore admin. If the owner field is set to the empty string (""), the ownership is updated to the System User.

databricks metastores update ID [flags]

Arguments

ID

    Unique ID of the metastore.

Options

--delta-sharing-organization-name string

    The organization name of a Delta Sharing entity, to be used in Databricks-to-Databricks Delta Sharing as the official name.

--delta-sharing-recipient-token-lifetime-in-seconds int

    The lifetime of delta sharing recipient token in seconds.

--delta-sharing-scope DeltaSharingScopeEnum

    The scope of Delta Sharing enabled for the metastore. Supported values: INTERNAL, INTERNAL_AND_EXTERNAL

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

--new-name string

    New name for the metastore.

--owner string

    The owner of the metastore.

--privilege-model-version string

    Privilege model version of the metastore, of the form major.minor (e.g., 1.0).

--storage-root-credential-id string

    UUID of storage credential to access the metastore storage_root.

Global flags

Examples

The following example updates a metastore name:

databricks metastores update abc123-def456-ghi789 --new-name my-updated-metastore

The following example updates a metastore with Delta Sharing configuration:

databricks metastores update abc123-def456-ghi789 --delta-sharing-scope INTERNAL_AND_EXTERNAL --delta-sharing-organization-name my-org

databricks metastores update-assignment

Update a metastore assignment. This operation can be used to update metastore_id or default_catalog_name for a specified workspace, if the workspace is already assigned a metastore. The caller must be an account admin to update metastore_id; otherwise, the caller can be a workspace admin.

databricks metastores update-assignment WORKSPACE_ID [flags]

Arguments

WORKSPACE_ID

    A workspace ID.

Options

--default-catalog-name string

    The name of the default catalog in the metastore.

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

--metastore-id string

    The unique ID of the metastore.

Global flags

Examples

The following example updates a metastore assignment's default catalog:

databricks metastores update-assignment 123456789 --default-catalog-name new-default-catalog

The following example updates a metastore assignment's metastore ID:

databricks metastores update-assignment 123456789 --metastore-id new-metastore-id

Global flags

--debug

  Whether to enable debug logging.

-h or --help

    Display help for the Databricks CLI or the related command group or the related command.

--log-file string

    A string representing the file to write output logs to. If this flag is not specified then the default is to write output logs to stderr.

--log-format format

    The log format type, text or json. The default value is text.

--log-level string

    A string representing the log format level. If not specified then the log format level is disabled.

-o, --output type

    The command output type, text or json. The default value is text.

-p, --profile string

    The name of the profile in the ~/.databrickscfg file to use to run the command. If this flag is not specified then if it exists, the profile named DEFAULT is used.

--progress-format format

    The format to display progress logs: default, append, inplace, or json

-t, --target string

    If applicable, the bundle target to use