Updated on 2026-11-06 GMT+08:00

Alter View

Function

The ALTER VIEW statement is used to modify the metadata of a view, including renaming the view, and setting or dropping view properties.

Syntax

  • Rename a view.

    Iceberg, Lance, and Hive tables do not support renaming views.

    ALTER VIEW view_identifier RENAME TO view_identifier
  • Set view properties.
    ALTER VIEW view_identifier SET TBLPROPERTIES ( property_key = property_val [, ...] )
  • Drop view properties.
    ALTER VIEW view_identifier UNSET TBLPROPERTIES [ IF EXISTS ] ( property_key [, ...] )

Parameters

Parameter

Description

view_identifier

The view name, which can be qualified using database_name.view_name.

RENAME TO

Rename the view. The source and target databases must be the same. Moving views across databases is not supported.

SET TBLPROPERTIES

Set view properties. If the property key already exists, its value is replaced. If it does not exist, it is added.

UNSET TBLPROPERTIES

Drop view properties. If IF EXISTS is specified, no error is raised if the property does not exist.

property_key

The property key name, which can consist of multiple dot-separated parts, e.g., key_part1.key_part2.

Examples

Rename a view.

ALTER VIEW tempdb1.v1 RENAME TO tempdb1.v2;

Set view properties.

ALTER VIEW tempdb1.v2 SET TBLPROPERTIES ('created.by.user' = 'John', 'created.date' = '01-01-2001');

Drop view properties.

-- Drop existing properties.
ALTER VIEW tempdb1.v2 UNSET TBLPROPERTIES ('created.by.user', 'created.date');  
-- Use IF EXISTS to avoid an error if the property does not exist.
ALTER VIEW tempdb1.v2 UNSET TBLPROPERTIES IF EXISTS ('non-existent');

Precautions

  • ALTER VIEW only alters the metadata of the view and does not affect the underlying data.
  • When renaming a view, if the new view name already exists, a TableAlreadyExistsException is thrown.
  • Renaming a view clears the cached data for that view and its dependencies.
  • ALTER VIEW does not support SET SERDE or SET SERDEPROPERTIES.
  • WITH SCHEMA is not supported for TEMPORARY views.