kevinyu98 commented on a change in pull request #25573: 
[SPARK-28833][DOCS][SQL] Document ALTER VIEW command
URL: https://github.com/apache/spark/pull/25573#discussion_r344475265
 
 

 ##########
 File path: docs/sql-ref-syntax-ddl-alter-view.md
 ##########
 @@ -19,4 +19,78 @@ license: |
   limitations under the License.
 ---
 
-**This page is under construction**
+### Description
+The `ALTER VIEW` statement changes various auxiliary properties of a view.
+
+
+#### Rename view
+Rename the existing view. If the view name already exists in the database, an 
exception is thrown. This operation does 
+support moving the views cross databases. 
+##### Syntax
+{% highlight sql %}
+ALTER VIEW viewIdentifier RENAME TO viewIdentifier
+viewIdentifier:= [db_name.]view_name
+{% endhighlight %}
+
+
+#### Set view properties
+Set one or more properties of an existing view. The properties are the key 
value pairs. If the properties' keys exist, 
+the values are replaced with the new values. If the properties' keys does not 
exist, the key value pairs are added into 
+the properties.
+##### Syntax
+{% highlight sql %}
+ALTER VIEW viewIdentifier SET TBLPROPERTIES (key1=val1, key2=val2, ...)
+viewIdentifier:= [db_name.]view_name
+{% endhighlight %}
+
+
+#### Drop view properties
+Drop one or more properties of an existing view. If the specified keys do not 
exist, an exception is thrown. Use 
+`IF EXISTS` to avoid the exception. 
+##### Syntax
+{% highlight sql %}
+ALTER VIEW viewIdentifier UNSET TBLPROPERTIES [IF EXISTS] (key1=val1, 
key2=val2, ...)
+viewIdentifier:= [db_name.]view_name
+{% endhighlight %}
+
+
+#### Alter View As Select
+`ALTER VIEW AS SELECT` statement changes the definition of a view, the 
`select_statement` must valid, and the `VIEW` 
+must exist.
+##### Syntax
+{% highlight sql %}
+ALTER VIEW viewIdentifier AS select_statement
+viewIdentifier:= [db_name.]view_name
+select_statement:= [select_statement](sql-ref-syntax-qry-select.html)
+{% endhighlight %}
+
+
+#### Example
+{% highlight sql %}
+-- Rename only change the view name.
+-- The source and target databases of the view have to be the same, use 
qualified or unqualified name for the target view  
+ALTER VIEW tempdb.view1 RENAME TO view2
+{% endhighlight %}
+
+{% highlight sql %}
+-- Use `DESC TABLE EXTENDED tempdb.view1` before and after the `ALTER VIEW` 
statement to verify the changes.
+ALTER VIEW tempdb.view1 SET TBLPROPERTIES ('propKey1' = "propVal1", 'propKey2' 
= "propVal2" )
+{% endhighlight %}
+
+{% highlight sql %}
+-- Use `DESC TABLE EXTENDED tempdb.view1` before and after the `ALTER VIEW` to 
verify the change.
+ALTER VIEW tempdb.view1 UNSET TBLPROPERTIES ('propKey1')
+{% endhighlight %}
+
+{% highlight sql %}
+-- Do the select on tempdb.view1 before and after the `ALTER VIEW` statement 
to verify.
+ALTER VIEW tempdb.view1 AS SELECT * FROM tempdb.view2
+{% endhighlight %}
+
+#### Related Statements
+[describe-table](sql-ref-syntax-aux-describe-table.html) 
+[create-view](sql-ref-syntax-ddl-create-view.html)
+[drop-view](sql-ref-syntax-ddl-drop-view.html)
 
 Review comment:
   👍

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to