blob: d27ce995e375dbd8605dfa085bf04824f511cf9a [file]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="copyright" content="(C) Copyright 2025" />
<meta name="DC.rights.owner" content="(C) Copyright 2025" />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="ALTER VIEW Statement" />
<meta name="DC.Relation" scheme="URI" content="../topics/impala_langref_sql.html" />
<meta name="prodname" content="Impala" />
<meta name="prodname" content="Impala" />
<meta name="version" content="Impala 3.4.x" />
<meta name="version" content="Impala 3.4.x" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="alter_view" />
<link rel="stylesheet" type="text/css" href="../commonltr.css" />
<title>ALTER VIEW Statement</title>
</head>
<body id="alter_view">
<h1 class="title topictitle1" id="ariaid-title1">ALTER VIEW Statement</h1>
<div class="body conbody">
<p class="p">
The <code class="ph codeph">ALTER VIEW</code> statement changes the characteristics of a view.
</p>
<p class="p">
Because a view is a logical construct, an alias for a query, with no physical data behind
it, <code class="ph codeph">ALTER VIEW</code> only involves changes to metadata in the metastore
database, not any data files in HDFS.
</p>
<p class="p">
To see the definition of the updated view, issue a <code class="ph codeph">DESCRIBE FORMATTED</code>
statement.
</p>
<p class="p">
<strong class="ph b">Syntax:</strong>
</p>
<pre class="pre codeblock"><code>ALTER VIEW [<var class="keyword varname">database_name</var>.]<var class="keyword varname">view_name</var>
[(<var class="keyword varname">column_name</var> [COMMENT '<var class="keyword varname">column_comment</var>'][, ...])]
AS <var class="keyword varname">select_statement</var>;
ALTER VIEW [<var class="keyword varname">database_name</var>.]<var class="keyword varname">view_name</var>
RENAME TO [<var class="keyword varname">database_name</var>.]<var class="keyword varname">view_name</var>;
ALTER VIEW [<var class="keyword varname">database_name</var>.]<var class="keyword varname">view_name</var> SET OWNER USER user_name;
ALTER VIEW [<var class="keyword varname">database_name</var>.]<var class="keyword varname">view_name</var>
SET TBLPROPERTIES ('<var class="keyword varname">name</var>' = '<var class="keyword varname">value</var>'[, '<var class="keyword varname">name</var>' = '<var class="keyword varname">value</var>' ...]);
ALTER VIEW [<var class="keyword varname">database_name</var>.]<var class="keyword varname">view_name</var>
UNSET TBLPROPERTIES ('<var class="keyword varname">name</var>'[, ...]);
</code></pre>
<ul class="ul">
<li class="li">
The <code class="ph codeph">AS</code> clause associates the view with a different query.
<p class="p">
An optional list of column names can be specified with or without the column-level
comments.
</p>
<div class="p">
For example:
<pre class="pre codeblock"><code>
ALTER VIEW v1 AS SELECT x, UPPER(s) s FROM t2;
ALTER VIEW v1 (c1, c2) AS SELECT x, UPPER(s) s FROM t2;
ALTER VIEW v7 (c1 COMMENT 'Comment for c1', c2) AS SELECT t1.c1, t1.c2 FROM t1;
</code></pre>
</div>
</li>
<li class="li">
The <code class="ph codeph">RENAME TO</code> clause changes the name of the view, moves the view to a
different database, or both.
<div class="p">
For example:
<pre class="pre codeblock"><code>ALTER VIEW db1.v1 RENAME TO db2.v2; -- Move the view to a different database with a new name.
ALTER VIEW db1.v1 RENAME TO db1.v2; -- Rename the view in the same database.
ALTER VIEW db1.v1 RENAME TO db2.v1; -- Move the view to a difference database with the same view name.</code></pre>
</div>
</li>
<li class="li">
The <code class="ph codeph">SET OWNER</code> clause transfers the ownership of the view from the
current owner to another user.
<p class="p">
The view owner is originally set to the user who creates the view.
The term <code class="ph codeph">OWNER</code> is used to differentiate between the
<code class="ph codeph">ALL</code> privilege that is explicitly granted via the
<code class="ph codeph">GRANT</code> statement and a privilege that is implicitly granted by the
<code class="ph codeph">CREATE VIEW</code> statement.
</p>
</li>
<li class="li">
The <code class="ph codeph">SET TBLPROPERTIES</code> clause is primarily a way to associate arbitrary
user-specified data items with a particular view.
<p class="p">
You can associate arbitrary items of metadata with a table by specifying the
<code class="ph codeph">TBLPROPERTIES</code> clause. This clause takes a comma-separated list of
key-value pairs and stores those items in the metastore database. You can also unset the
view properties later with an <code class="ph codeph">UNSET TBLPROPERTIES</code> clause.
</p>
<div class="p">
For example:
<pre class="pre codeblock"><code>ALTER VIEW v1 SET TBLPROPERTIES ('tblp1' = '1', 'tblp2' = '2');
ALTER VIEW v1 UNSET TBLPROPERTIES ('tblp1', 'tblp2');
</code></pre>
</div>
</li>
</ul>
<p class="p">
<strong class="ph b">Statement type:</strong> DDL
</p>
<p class="p">
If you connect to different Impala nodes within an <span class="keyword cmdname">impala-shell</span>
session for load-balancing purposes, you can enable the <code class="ph codeph">SYNC_DDL</code> query
option to make each DDL statement wait before returning, until the new or changed
metadata has been received by all the Impala nodes. See
<a class="xref" href="../shared/../topics/impala_sync_ddl.html#sync_ddl">SYNC_DDL Query Option</a> for details.
</p>
<p class="p">
<strong class="ph b">Security considerations:</strong>
</p>
<p class="p">
If these statements in your environment contain sensitive literal values such as credit
card numbers or tax identifiers, Impala can redact this sensitive information when
displaying the statements in log files and other administrative contexts. See
<span class="xref">the documentation for your Apache Hadoop distribution</span> for details.
</p>
<p class="p">
<strong class="ph b">Cancellation:</strong> Cannot be cancelled.
</p>
<p class="p">
<strong class="ph b">HDFS permissions:</strong> This statement does not touch any HDFS files or directories,
therefore no HDFS permissions are required.
</p>
<p class="p">
<strong class="ph b">Related information:</strong>
</p>
<p class="p">
<a class="xref" href="impala_views.html#views">Overview of Impala Views</a>, <a class="xref" href="impala_create_view.html#create_view">CREATE VIEW Statement</a>,
<a class="xref" href="impala_drop_view.html#drop_view">DROP VIEW Statement</a>
</p>
</div>
<div class="related-links">
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/impala_langref_sql.html">Impala SQL Statements</a></div>
</div>
</div></body>
</html>