CREATE SHARE

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 10.3 and above check marked yes Unity Catalog only

Creates a share with the specified name. If a share with the same name already exists, an exception is thrown.

To create a share, you must be a metastore admin or have the CREATE SHARE privilege for the Unity Catalog metastore where the data you want to share is registered.

To add content to the share, use ALTER SHARE.

Syntax

CREATE SHARE [ IF NOT EXISTS ] share_name
    [ COMMENT comment ]

Parameters

  • share_name

    The name of the share to be created.

  • IF NOT EXISTS

    Creates a share with the given name if it does not exist. If a share with the same name already exists, nothing will happen.

  • comment

    An optional STRING literal. The description for the share.

Examples

-- Create share `customer_share`. This throws exception if a share with name customer_share
-- already exists.
> CREATE SHARE customer_share;

-- Create share `customer_share` only if share with same name doesn't exist.
> CREATE SHARE IF NOT EXISTS customer_share;

-- Create share `customer_share` only if share with same name doesn't exist, with a comment.
> CREATE SHARE IF NOT EXISTS customer_share COMMENT 'This is customer share';