Share via


schemas 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 schemas command group within the Databricks CLI contains commands to manage schemas in Unity Catalog. A schema is the second layer of Unity Catalog's three-level namespace. A schema organizes tables, views and functions. See What are schemas in Azure Databricks?.

databricks schemas create

Create a new schema for catalog in the metastore. The caller must be a metastore admin, or have the CREATE_SCHEMA privilege in the parent catalog.

databricks schemas create NAME CATALOG_NAME [flags]

Arguments

NAME

    Name of schema, relative to parent catalog.

CATALOG_NAME

    Name of parent catalog.

Options

--comment string

    User-provided free-form text description.

--json JSON

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

--storage-root string

    Storage root URL for managed tables within schema.

Global flags

Examples

The following example creates a new schema named analytics in the main catalog:

databricks schemas create analytics main

The following example creates a new schema with a comment:

databricks schemas create analytics main --comment "Schema for analytics data"

databricks schemas delete

Delete the specified schema from the parent catalog. The caller must be the owner of the schema or an owner of the parent catalog.

databricks schemas delete FULL_NAME [flags]

Arguments

FULL_NAME

    Full name of the schema.

Options

--force

    Force deletion even if the schema is not empty.

Global flags

Examples

The following example deletes a schema:

databricks schemas delete main.analytics

The following example force deletes a schema even if it's not empty:

databricks schemas delete main.analytics --force

databricks schemas get

Get the specified schema within the metastore. The caller must be a metastore admin, the owner of the schema, or a user that has the USE_SCHEMA privilege on the schema.

databricks schemas get FULL_NAME [flags]

Arguments

FULL_NAME

    Full name of the schema.

Options

--include-browse

    Whether to include schemas in the response for which the principal can only access selective metadata for.

Global flags

Examples

The following example gets information about a schema:

databricks schemas get main.analytics

The following example gets schema information including browse permissions:

databricks schemas get main.analytics --include-browse

databricks schemas list

List the schemas for a catalog in the metastore. If the caller is the metastore admin or the owner of the parent catalog, all schemas for the catalog will be retrieved. Otherwise, only schemas owned by the caller (or for which the caller has the USE_SCHEMA privilege) will be retrieved. There is no guarantee of a specific ordering of the elements in the array.

databricks schemas list CATALOG_NAME [flags]

Arguments

CATALOG_NAME

    Parent catalog for schemas of interest.

Options

--include-browse

    Whether to include schemas in the response for which the principal can only access selective metadata for.

--max-results int

    Maximum number of schemas 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 schemas in the main catalog:

databricks schemas list main

The following example lists schemas with a maximum of 10 results:

databricks schemas list main --max-results 10

The following example lists schemas using pagination:

databricks schemas list main --page-token <token>

databricks schemas update

Update a schema for a catalog. The caller must be the owner of the schema or a metastore admin. If the caller is a metastore admin, only the owner field can be changed in the update. If the name field must be updated, the caller must be a metastore admin or have the CREATE_SCHEMA privilege on the parent catalog.

databricks schemas update FULL_NAME [flags]

Arguments

FULL_NAME

    Full name of the schema.

Options

--comment string

    User-provided free-form text description.

--enable-predictive-optimization EnablePredictiveOptimization

    Whether predictive optimization should be enabled for this object and objects under it. Supported values: [DISABLE, ENABLE, INHERIT]

--json JSON

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

--new-name string

    New name for the schema.

--owner string

    Username of current owner of schema.

Global flags

Examples

The following example updates a schema's comment:

databricks schemas update main.analytics --comment "Updated analytics schema"

The following example changes the owner of a schema:

databricks schemas update main.analytics --owner someone@example.com

The following example renames a schema:

databricks schemas update main.analytics --new-name analytics_v2

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