---
title: ALTER TABLE
description: Change the schema, properties, or partitions of a table, or convert external and foreign tables to managed tables, with ALTER TABLE.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table
---

# ALTER TABLE

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Alters the schema or properties of a table.

Temporary tables support `ALTER TABLE ... SET TBLPROPERTIES` and `ALTER TABLE ... UNSET TBLPROPERTIES` in serverless compute, Databricks Runtime 18.2 and above, and Databricks SQL 2026.15 and above. Other `ALTER TABLE` clauses are not supported on temporary tables and return an error. If the table is cached, the command clears cached data of the table and all its dependents that refer to it. The cache will be lazily filled when the table or the dependents are accessed the next time.

Foreign tables support a limited set of `ALTER TABLE` operations, including `ALTER TABLE SET OWNER`, `ALTER TABLE RENAME TO`, `ALTER TABLE SET MANAGED { MOVE | COPY }`, and `ALTER TABLE SET EXTERNAL`. `SET MANAGED` and `SET EXTERNAL` require a foreign table federated using [Hive metastore and Glue Federation](https://docs.databricks.com/aws/en/query-federation/hms-federation-concepts.md), and `SET MANAGED` also requires the Delta Lake format. See [Foreign tables](https://docs.databricks.com/aws/en/tables/convert-to-managed.md#prereqs-foreign) and [Convert a foreign table to an external Unity Catalog table](https://docs.databricks.com/aws/en/tables/convert-foreign-external.md).

## Required permissions

If you use Unity Catalog you must have `MODIFY` permission to:

* `ALTER COLUMN`
* `ADD COLUMN`
* `DROP COLUMN`
* `SET TBLPROPERTIES`
* `UNSET TBLPROPERTIES`

If you use Unity Catalog you must have `MANAGE` permission or ownership to:

* `SET OWNER TO`
* `PREDICTIVE OPTIMIZATION`
* `SET MANAGED`
* `UNSET MANAGED`

All other operations require ownership of the table.

`SET EXTERNAL` also requires `CREATE` permission on the `EXTERNAL LOCATION`. For foreign tables, `SET MANAGED MOVE` also requires `CREATE EXTERNAL TABLE` on the external location that covers the source table's path. `SET MANAGED COPY` doesn't require any privilege on the external location. For the full prerequisites for each conversion, see [Prerequisites](https://docs.databricks.com/aws/en/tables/convert-to-managed.md#prerequisites) and [Prerequisites](https://docs.databricks.com/aws/en/tables/convert-foreign-external.md#prerequisites).

## Syntax

```
ALTER TABLE table_name
    { RENAME TO clause |
      ADD COLUMN clause |
      ALTER COLUMN clause |
      DROP COLUMN clause |
      RENAME COLUMN clause |
      DEFAULT COLLATION clause |
      ADD CONSTRAINT clause |
      DROP CONSTRAINT clause |
      DROP FEATURE clause |
      ADD PARTITION clause |
      DROP PARTITION clause |
      PARTITION SET LOCATION clause |
      RENAME PARTITION clause |
      RECOVER PARTITIONS clause |
      SET { ROW FILTER clause } |
      DROP ROW FILTER |
      SET TBLPROPERTIES clause |
      UNSET TBLPROPERTIES clause |
      SET SERDE clause |
      SET LOCATION clause |
      SET EXTERNAL clause |
      SET MANAGED clause |
      UNSET MANAGED clause |
      SET OWNER TO clause |
      SET TAGS clause |
      UNSET TAGS clause |
      CLUSTER BY clause |
      REPLACE PARTITIONED BY WITH CLUSTER BY clause |
      PREDICTIVE OPTIMIZATION clause}
```

## Parameters

* **[table\_name](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#table-name)**

  Identifies the table being altered. The name must not include a [temporal specification or options specification](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#table-name).
  If the table cannot be found Databricks raises a [TABLE\_OR\_VIEW\_NOT\_FOUND](https://docs.databricks.com/aws/en/error-messages/table-or-view-not-found-error-class.md) error.

* **`RENAME TO` [to\_table\_name](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#table-name)**

  Renames the table.

  > [!NOTE]
  >
  > If you use AWS Glue Data Catalog as the metastore, RENAME is not supported.

  * **[to\_table\_name](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#table-name)**

    Identifies the new table name. The name must not include a [temporal specification or options specification](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#table-name).

    For Unity Catalog tables, the `to_table_name` must be within the same catalog as `table_name`.
    For other tables, the `to_table_name` must be within the same schema as `table_name`.

    If `to_table_name` is unqualified it is implicitly qualified with the current schema.

  ```sql
  > ALTER TABLE student RENAME TO student_info;
  ```

* **[ADD COLUMN](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-column.md#add-column)**

  Adds one or more columns to the table.

  When you add a column to an existing Delta Lake table, you cannot define a `DEFAULT` value. All columns added to Delta Lake tables are treated as `NULL` for existing rows. After adding a column, you can optionally define a default value for new rows using `ALTER COLUMN`.

  ```sql
  > DESCRIBE StudentInfo;
                  col_name data_type comment
   ----------------------- --------- -------
                      name    string    NULL
                    rollno       int    NULL
                       age       int    NULL

  > ALTER TABLE StudentInfo ADD columns (LastName string, DOB timestamp);

  -- After adding new columns to the table
  > DESCRIBE StudentInfo;
                  col_name data_type comment
   ----------------------- --------- -------
                      name    string    NULL
                    rollno       int    NULL
                  LastName    string    NULL
                       DOB timestamp    NULL
                       age       int    NULL

  -- Optionally set a default value for new rows
  > ALTER TABLE StudentInfo ALTER COLUMN LastName SET DEFAULT 'unknown';
  ```

<a id="change-column" />

* **[ALTER COLUMN](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-column.md#alter-column)**

  Changes a property or the location of a column.

  ```sql
  > DESCRIBE StudentInfo;
                  col_name data_type comment
   ----------------------- --------- -------
                      name    string    NULL
                    rollno       int    NULL
                  LastName    string    NULL
                       DOB timestamp    NULL
                       age       int    NULL

  > ALTER TABLE StudentInfo ALTER COLUMN name COMMENT "new comment";

  -- After altering the column
  > DESCRIBE StudentInfo;
                  col_name data_type     comment
   ----------------------- --------- -----------
                      name    string new comment
                    rollno       int        NULL
                  LastName    string        NULL
                       DOB timestamp        NULL
                       age       int        NULL
  ```

  Alter multiple columns in a single statement:

  ```sql
  -- Create a table with 3 columns
  > CREATE TABLE my_table (num INT, str STRING, bool BOOLEAN) TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'supported')
  > DESCRIBE TABLE my_table;
    col_name    data_type     comment
    --------    ---------     -------
         num          int        null
         str       string        null
         bool      boolean       null

  -- Update comments on multiple columns
  > ALTER TABLE table ALTER COLUMN
     num COMMENT 'number column',
     str COMMENT 'string column';

  > DESCRIBE TABLE my_table;
    col_name    data_type      comment
    --------    ---------   -------------
         num          int   number column
         str       string   string column
        bool      boolean            null

  -- Can mix different types of column alter
  > ALTER TABLE table ALTER COLUMN
     bool COMMENT 'boolean column',
     num AFTER bool,
     str AFTER num,
     bool SET DEFAULT true;

  > DESCRIBE TABLE my_table;
    col_name    data_type      comment
    --------    ---------   --------------
        bool      boolean   boolean column
         num          int    number column
         str       string    string column
  ```

* **[DROP COLUMN](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-column.md#drop-column)**

  Drop one or more columns or fields in a Delta Lake table.

* **[RENAME COLUMN](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-column.md#rename-column)**

  Renames a column or field in a Delta Lake table.

  ```sql
  > ALTER TABLE StudentInfo RENAME COLUMN name TO FirstName;

  -- After renaming the column
  > DESCRIBE StudentInfo;
                  col_name data_type     comment
   ----------------------- --------- -----------
                 FirstName    string new comment
                    rollno       int        NULL
                  LastName    string        NULL
                       DOB timestamp        NULL
                       age       int        NULL
  ```

<a id="add-constraint" />

* **[ADD CONSTRAINT](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-add-constraint.md)**

  Adds a check constraint, informational foreign key constraint, or informational primary key constraint to the table.

  Foreign keys and primary keys are supported only for tables in Unity Catalog, not the `hive_metastore` catalog.

* **`DEFAULT COLLATION` [collation\_name](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#collation-name)**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 16.3 and above

  Changes the default collation of the table for new `STRING` columns.
  Existing columns are not affected by this clause.
  To change the collation of an existing column, use `ALTER TABLE ... ALTER COLUMN ... COLLATE collation_name`.

<a id="drop-constraint" />

* **[DROP CONSTRAINT](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-drop-constraint.md)**

  Drops a primary key, foreign key, or check constraint from the table.

* **`DROP FEATURE feature_name [ TRUNCATE HISTORY ]`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 14.3 LTS and above

  Legacy support for `DROP FEATURE` is available starting in Databricks Runtime 14.3 LTS.
  For documentation of the legacy functionality, see [Drop Delta table features (legacy)](https://docs.databricks.com/aws/en/archive/legacy/drop-feature-legacy.md).

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 16.3 and above

* Databricks recommends using Databricks Runtime 16.3 and above for all `DROP FEATURE` commands, which replaces the legacy behavior.

  Removes a feature from a Delta Lake table.

  Removing a feature may result in the addition of the `checkpointProtection` writer feature in the table protocol.
  For more information, see [Drop Delta table features](https://docs.databricks.com/aws/en/tables/features/drop-feature.md) and [Protocol versions and table features](https://docs.databricks.com/aws/en/tables/features/feature-compatibility.md#table-features).

  * `feature_name`

    The name of a feature in form of a `STRING` literal or [identifier](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-identifiers.md), that must be understood by Databricks and be supported on the table.

    If the feature is not present in the table Databricks raises [DELTA\_FEATURE\_DROP\_FEATURE\_NOT\_PRESENT](https://docs.databricks.com/aws/en/error-messages/error-classes.md#delta_feature_drop_feature_not_present).

  * **TRUNCATE HISTORY**

    Removal of features by truncating history. This requires a two stage process:

The removal of features by truncating history requires a two-step process:

* The first invocation clears traces of the feature and informs you of partial success.

* Then, wait until the retention period ends before re-executing the statement to complete the removal.

  If you initiate the second invocation too early, Databricks raises [DELTA\_FEATURE\_DROP\_WAIT\_FOR\_RETENTION\_PERIOD](https://docs.databricks.com/aws/en/error-messages/error-classes.md#delta_feature_drop_wait_for_retention_period) or [DELTA\_FEATURE\_DROP\_HISTORICAL\_VERSIONS\_EXIST](https://docs.databricks.com/aws/en/error-messages/error-classes.md#delta_feature_drop_historical_versions_exist).

  Truncating the table history limits your ability to perform [DESCRIBE HISTORY](https://docs.databricks.com/aws/en/sql/language-manual/delta-describe-history.md) and execute time travel queries.

  ```sql
  -- Drop the "deletion vectors" from a Delta table
  > ALTER TABLE my_table DROP FEATURE deletionVectors;

  -- 24 hours later
  > ALTER TABLE my_table DROP FEATURE deletionVectors TRUNCATE HISTORY;
  ```

* **[ADD PARTITION](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-partition.md#add-partition)**

  Adds one or more partitions to the table.

  ```sql
  > SHOW PARTITIONS StudentInfo;
   partition
   ---------
      age=11
      age=12
      age=15

  > ALTER TABLE StudentInfo ADD IF NOT EXISTS PARTITION (age=18);

  -- After adding a new partition to the table
  > SHOW PARTITIONS StudentInfo;
   partition
   ---------
      age=11
      age=12
      age=15
      age=18

  -- Adding multiple partitions to the table
  > ALTER TABLE StudentInfo ADD IF NOT EXISTS PARTITION (age=18) PARTITION (age=20);

  > SHOW PARTITIONS StudentInfo;
   partition
   ---------
      age=11
      age=12
      age=15
      age=18
      age=20
  ```

* **[DROP PARTITION](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-partition.md#drop-partition)**

  Drops one or more partitions from the table.

  ```sql
  > SHOW PARTITIONS StudentInfo;
   partition
   ---------
      age=11
      age=12
      age=15
      age=18

  > ALTER TABLE StudentInfo DROP IF EXISTS PARTITION (age=18);

  -- After dropping the partition of the table
  > SHOW PARTITIONS StudentInfo;
   partition
   ---------
      age=11
      age=12
      age=15
  ```

* **[PARTITION … SET LOCATION](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-partition.md#partition-set-location)**

  Sets the location of a partition.

  ```sql
  > ALTER TABLE dbx.tab1 PARTITION (a='1', b='2') SET LOCATION '/path/to/part/ways';
  ```

* **[RENAME PARTITION](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-partition.md#rename-partition)**

  Replaces the keys of a partition.

  ```sql
  > SHOW PARTITIONS StudentInfo;
   partition
   ---------
      age=10
      age=11
      age=12

  > ALTER TABLE default.StudentInfo PARTITION (age='10') RENAME TO PARTITION (age='15');

  -- After renaming Partition
  > SHOW PARTITIONS StudentInfo;
   partition
   ---------
      age=11
      age=12
      age=15
  ```

* **[RECOVER PARTITIONS](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-partition.md#recover-partitions)**

  Instructs Databricks to scan the table's location and add any files to the table which have been added directly to the filesystem.

* **`SET` [ROW FILTER clause](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-row-filter.md)**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.2 LTS and above ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Unity Catalog only

  Adds a row filter function to the table. All subsequent queries to the table receive a subset of the rows where the function evaluates to boolean TRUE. This can be useful for fine-grained access control purposes where the function can inspect the identity or group memberships of the invoking user to determine whether to filter certain rows.

* **`DROP ROW FILTER`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Unity Catalog only

  Drops the row filter from the table, if any.
  Future queries will return all rows from the table without any automatic filtering.

* **[SET TBLPROPERTIES](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-tblproperties.md#set-tblproperties)**

  Sets or resets one or more user defined properties.

  ```sql
  > ALTER TABLE dbx.tab1 SET TBLPROPERTIES ('winner' = 'loser');
  ```

* **[UNSET TBLPROPERTIES](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-tblproperties.md#unset-tblproperties)**

  Removes one or more user defined properties.

  ```sql
  > ALTER TABLE dbx.tab1 UNSET TBLPROPERTIES ('winner');
  ```

* **`SET SERDE`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

  Specifies the serializer/deserializer (SerDe) class used to read and write data in a Hive-format table. You can also configure SerDe properties with `WITH SERDEPROPERTIES`.

  ```sql
  > ALTER TABLE test_tab SET SERDE 'org.apache.hadoop.hive.serde2.columnar.LazyBinaryColumnarSerDe';

  > ALTER TABLE dbx.tab1 SET SERDE 'org.apache.hadoop' WITH SERDEPROPERTIES ('k' = 'v', 'kay' = 'vee');
  ```

* **`SET LOCATION`**

  Moves the location of a table.

  ```
  SET LOCATION path
  ```

  * **`LOCATION path`**

    `path` must be a `STRING` literal.
    Specifies the new location for the table.

    Files in the original location will **not** be moved to the new location.

<a id="set-external" />

* **`SET EXTERNAL [ DRY RUN ]`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 17.3 and above ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Unity Catalog only

  Converts a foreign table to a Unity Catalog external table, retaining the table history and configurations, including the name, settings, permissions, and views. Supported only on foreign tables federated using [Hive metastore and Glue Federation](https://docs.databricks.com/aws/en/query-federation/hms-federation-concepts.md).

  Requires `OWNER` or `MANAGE` permissions on the table and `CREATE` permission on the `EXTERNAL LOCATION`.

  To roll back the conversion, drop the table. Databricks re-federates it as a foreign table during the next catalog sync.

  * **`DRY RUN`**

    Checks whether the source table can be converted, without converting it. The command returns `DRY_RUN_SUCCESS` if the table can be converted.

  For prerequisites and format-specific guidance, see [Convert a foreign table to an external Unity Catalog table](https://docs.databricks.com/aws/en/tables/convert-foreign-external.md).

  ```sql
  -- Check whether a foreign table can be converted
  > ALTER TABLE hms_federated_catalog.my_schema.my_table SET EXTERNAL DRY RUN;

  -- Convert a foreign table to an external table
  > ALTER TABLE hms_federated_catalog.my_schema.my_table SET EXTERNAL;
  ```

<a id="set-managed" />

* **`SET MANAGED`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 17.3 LTS and above ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Unity Catalog only

  Converts a Unity Catalog external or foreign Delta Lake table to a Unity Catalog managed table. The conversion retains the table name, settings, permissions, views, and history.

  External and foreign tables use different forms of the clause, as shown in the following syntax:

  ```
  SET MANAGED [ TRUNCATE UNIFORM HISTORY ]  -- external tables
  SET MANAGED { MOVE | COPY }               -- foreign tables
  ```

  For external tables, omit `MOVE` and `COPY`. If you include either one, Databricks raises [DELTA\_ALTER\_TABLE\_SET\_MANAGED\_UNSUPPORTED\_COPY\_MOVE\_SYNTAX](https://docs.databricks.com/aws/en/error-messages/error-classes.md#delta_alter_table_set_managed_unsupported_copy_move_syntax).

  For foreign tables, specify either `MOVE` or `COPY`. If you omit both, Databricks raises [DELTA\_ALTER\_TABLE\_SET\_MANAGED\_COPY\_OR\_MOVE\_REQUIRED](https://docs.databricks.com/aws/en/error-messages/error-classes.md#delta_alter_table_set_managed_copy_or_move_required). To choose between the two forms, see [Choose the correct command for your source table](https://docs.databricks.com/aws/en/tables/convert-to-managed.md#which-command).

  * **`TRUNCATE UNIFORM HISTORY`**

    Applies to external tables that have [Apache Iceberg reads](https://docs.databricks.com/aws/en/delta/iceberg-reads.md) enabled. If the table has Iceberg reads enabled and you omit this option, Databricks raises [DELTA\_ALTER\_TABLE\_SET\_MANAGED\_DOES\_NOT\_SUPPORT\_UNIFORM\_ICEBERG](https://docs.databricks.com/aws/en/error-messages/error-classes.md#delta_alter_table_set_managed_does_not_support_uniform_iceberg).

    `TRUNCATE UNIFORM HISTORY` truncates UniForm Iceberg history and doesn't remove Delta Lake history. Truncation causes a short Iceberg read and write downtime.

  * **`MOVE`**

    Converts a foreign table to managed and disables access to the source table in the external catalog. After conversion, access through the external catalog and path-based access fail, so all readers and writers must use the Unity Catalog namespace.

  * **`COPY`**

    Converts a foreign table to managed without modifying or disabling access to the source table in the external catalog. The conversion copies data into the managed storage location, creating two separate copies of the data. You are responsible for disabling reads and writes to the source table and migrating workloads to the managed table.

  For prerequisites and downtime estimates, see [Convert external or foreign Delta Lake tables to Unity Catalog managed tables](https://docs.databricks.com/aws/en/tables/convert-to-managed.md). To troubleshoot a failed conversion, see [Troubleshoot conversion failures](https://docs.databricks.com/aws/en/tables/convert-to-managed-rollback.md#troubleshooting).

  ```sql
  -- Convert an external table
  > ALTER TABLE main.default.my_external_table SET MANAGED;

  -- Convert an external table that has Iceberg reads enabled
  > ALTER TABLE main.default.my_external_table SET MANAGED TRUNCATE UNIFORM HISTORY;

  -- Convert a foreign table and disable access to the source table
  > ALTER TABLE hms_federated_catalog.my_schema.my_table SET MANAGED MOVE;
  ```

* **`UNSET MANAGED`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 17.3 LTS and above ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Unity Catalog only

  Rolls a table converted with `SET MANAGED` back to an external table by updating the table metadata to point to the original external location. Databricks preserves writes made to the managed location after conversion. For a converted external table, you can roll back within 14 days of conversion.

  ```
  UNSET MANAGED [ TRUNCATE UNIFORM HISTORY ]
  ```

  * **`TRUNCATE UNIFORM HISTORY`**

    Applies to tables that have Iceberg reads enabled. If the table has Iceberg reads enabled and you omit this option, Databricks raises [DELTA\_ALTER\_TABLE\_UNSET\_MANAGED\_DOES\_NOT\_SUPPORT\_UNIFORM](https://docs.databricks.com/aws/en/error-messages/error-classes.md#delta_alter_table_unset_managed_does_not_support_uniform).

  Commits made between conversion and rollback support time travel by version, but not by timestamp.

  To roll a foreign table converted with `MOVE` back to a foreign table, run `UNSET MANAGED` and then drop the resulting external table, which re-federates it during the next catalog sync. `UNSET MANAGED` isn't supported for a foreign table converted with `COPY`, and the command fails. The conversion left the source table unmodified, so to roll back, drop the managed table, which re-federates it during the next catalog sync.

  > [!WARNING]
  >
  > If you converted a foreign table with `MOVE`, do not drop the managed table before you run `UNSET MANAGED`. Dropping it first might result in data loss or inconsistencies.

  For full rollback instructions, see [Roll back a managed table conversion](https://docs.databricks.com/aws/en/tables/convert-to-managed-rollback.md#rollback).

  ```sql
  -- Roll a converted managed table back to an external table
  > ALTER TABLE main.default.my_managed_table UNSET MANAGED;
  ```

* **`[ SET ] OWNER TO` [principal](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-principal.md)**

  Transfers ownership of the table to `principal`.

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 11.3 LTS and above

  `SET` is allowed as an optional keyword.

  > [!NOTE]
  >
  > Changing the owner is not available on datasets managed by a workspace pipeline.

* **`SET TAGS ( { tag_name = tag_value } [, ...] )`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 13.3 LTS and above

  Apply tags to the table. You need to have `APPLY TAG` permission to add tags to the table.

  * **tag\_name**

    A literal `STRING`. The `tag_name` must be unique within the table or column.

  * **tag\_value**

    A literal `STRING`.

  ```sql
  -- Applies three tags to the table named `test`.
  > ALTER TABLE test SET TAGS ('tag1' = 'val1', 'tag2' = 'val2', 'tag3' = 'val3');

  -- Applies three tags to table `main.schema1.test` column `col1`.
  > ALTER TABLE main.schema1.test ALTER COLUMN col1 SET TAGS ('tag1' = 'val1', 'tag2' = 'val2', 'tag3' = 'val3');
  ```

* **`UNSET TAGS ( tag_name [, ...] )`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 13.3 LTS and above

  Remove tags from the table. You need to have `APPLY TAG` permission to remove tags from the table.

  * **tag\_name**

    A literal `STRING`. The `tag_name` must be unique within the table or column.

  ```sql
  -- Removes three tags from the table named `test`.
  > ALTER TABLE test UNSET TAGS ('tag1', 'tag2', 'tag3');

  -- Removes three tags from table `main.schema1.test` column `col1`.
  > ALTER TABLE main.schema1.test ALTER COLUMN col1 UNSET TAGS ('tag1', 'tag2', 'tag3');
  ```

* **[CLUSTER BY clause](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-cluster-by.md)**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 13.3 LTS and above

  Adds, changes, or drops the clustering strategy for a Delta Lake table.

* **`REPLACE PARTITIONED BY WITH CLUSTER BY [( <clustering_columns> ) | AUTO]`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 18.1 and above

  Converts an existing partitioned Delta Lake table to liquid clustering in place, with minimal reader and writer downtime. The `CLUSTER BY` clause accepts explicit clustering columns, `AUTO` to delegate key selection to predictive optimization, or can be omitted to use the existing partition columns.

  See [Convert a partitioned table to liquid clustering](https://docs.databricks.com/aws/en/tables/convert-to-liquid-clustering.md).

* **`{ ENABLE | DISABLE | INHERIT } PREDICTIVE OPTIMIZATION`**

  **Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 12.2 LTS and above ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Unity Catalog only

  Alters the managed Delta Lake table to the desired predictive optimization setting.

  By default, when tables are created, the behavior is to `INHERIT` from the schema.

  When predictive optimization is explicitly enabled or inherited as enabled [OPTIMIZE](https://docs.databricks.com/aws/en/sql/language-manual/delta-optimize.md) and [VACUUM](https://docs.databricks.com/aws/en/sql/language-manual/delta-vacuum.md) will be automatically invoked on the table as deemed appropriate by Databricks. For more details see: [Predictive optimization for Unity Catalog managed tables](https://docs.databricks.com/aws/en/optimizations/predictive-optimization.md).

  ```sql
  -- Enables predictive optimization for my_table
  > ALTER TABLE my_table ENABLE PREDICTIVE OPTIMIZATION;
  ```

## <a id="examples" />Additional examples

For Delta Lake add constraints and alter column examples, see

* [Update table schemas with schema evolution](https://docs.databricks.com/aws/en/tables/update-schema.md)
* [Constraints on Databricks](https://docs.databricks.com/aws/en/tables/constraints.md)

## Related articles

* [ADD CONSTRAINT clause](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-add-constraint.md): Add or drop check constraints, primary keys, and foreign keys.
* [ALTER MATERIALIZED VIEW](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-materialized-view.md): Syntax for altering materialized views.
* [ALTER STREAMING TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-streaming-table.md): Syntax for altering streaming tables.
* [ALTER TABLE ... COLUMN clause](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-column.md): Full syntax for ADD, ALTER, DROP, and RENAME COLUMN.
* [ALTER TABLE … PARTITION](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table-manage-partition.md): Full syntax for adding, dropping, and renaming partitions.
* [Update table schemas with schema evolution](https://docs.databricks.com/aws/en/tables/update-schema.md): Rename or change column types in a Delta table.
* [Convert external or foreign Delta Lake tables to Unity Catalog managed tables](https://docs.databricks.com/aws/en/tables/convert-to-managed.md): Prerequisites and downtime estimates for `SET MANAGED`.
* [Troubleshoot and roll back managed table conversions](https://docs.databricks.com/aws/en/tables/convert-to-managed-rollback.md): Troubleshooting and rollback for `SET MANAGED` conversions.
* [Convert a foreign table to an external Unity Catalog table](https://docs.databricks.com/aws/en/tables/convert-foreign-external.md): Prerequisites and format-specific guidance for `SET EXTERNAL`.
