ALTER SHARE

Preview

Delta Sharing is in Public Preview. To participate in the preview, you must enable the External Data Sharing feature group in the Databricks Account Console. See Enable the External Data Sharing feature group for your account.

Delta Sharing is subject to applicable terms. Enabling the External Data Sharing feature group represents acceptance of those terms.

Adds or removes tables to or from the share. Transfers the ownership of a share to a new principal.

Since: Databricks Runtime 10.3

Syntax

ALTER share_name
  { alter_table |
    REMOVE TABLE clause }

alter_table
  { ADD [ TABLE ] table_name [ COMMENT comment ]
        [ PARTITION clause ] [ AS table_share_name ] }

Parameters

  • share_name

    The name of the share to be altered.

  • alter_table

    Adds a table or partitions of a table to the share.

    • ADD [ TABLE ] table_name

      Identifies the table to be added. The table must not reside in the hive_metastore.

    • COMMENT comment

      An optional string literal attached to the table share as a comment.

    • PARTITION clause

      One or to more partitions of the table to be added. The partition keys must match the partitioning of the table and be associated with values. If no PARTITION clause is present ADD TABLE adds the entire table.

    • AS table_share_name

      Optionally exposes the table under a different name. The name can be qualified with a database (schema) name. If no table_share_name is specified the table will be known under its own name.

  • REMOVE [ TABLE ] table_name

    Remove the table identified by table_name from the share.

Examples

-- Creates a share named `some_share`.
> CREATE SHARE some_share;

-- Add a table to the share.
> ALTER SHARE some_share
     ADD TABLE my_db.my_tab
         COMMENT 'some comment'
         PARTITION(c1_int = 5, c2_date LIKE '2021%')
         AS shared_db.shared_tab;

-- Remove the table again
> ALTER SHARE some_share
    REMOVE TABLE shared_db.shared_tab;