ALTER-VIEW

Name

ALTER VIEW

Description

This statement is used to modify the definition of a view

grammar:

1. ALTER VIEW
2. [db_name.]view_name
3. (column1[ COMMENT "col comment"][, column2, ...])
4. AS query_stmt

illustrate:

  • Views are all logical, and the data in them will not be stored on physical media. When querying, the view will be used as a subquery in the statement. Therefore, modifying the definition of the view is equivalent to modifying query_stmt.
  • query_stmt is any supported SQL

Example

  1. Modify the view example_view on example_db
1. ALTER VIEW example_db.example_view
2. (
3. c1 COMMENT "column 1",
4. c2 COMMENT "column 2",
5. c3 COMMENT "column 3"
6. )
7. AS SELECT k1, k2, SUM(v1) FROM example_table
8. GROUP BY k1, k2

Keywords

1. ALTER, VIEW

Best Practice