CREATE SHARE

适用范围:勾选“是” Databricks SQL 勾选“是” Databricks Runtime 10.4 LTS 及更高版本 勾选“是” 仅 Unity Catalog

创建具有指定名称的共享。 如果已存在同名共享,则会引发异常。

若要创建共享,你必须是元存储管理员,或者对要共享的数据所要注册到的 Unity Catalog 元存储拥有 CREATE SHARE 权限。

若要向共享添加内容,请使用 ALTER SHARE

语法

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

参数

  • share_name

    要创建的共享名称。

  • IF NOT EXISTS

    创建具有给定名称的共享(如果不存在)。 如果已存在同名共享,则不会执行任何操作。

  • comment

    可选的 STRING 文本。 共享的说明。

示例

-- 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';