ALTER VIEW

description

  1. This statement is used to modify the definition of a view
  2. Syntax:
  3. ALTER VIEW
  4. [db_name.]view_name
  5. (column1[ COMMENT "col comment"][, column2, ...])
  6. AS query_stmt
  7. Explain:
  8. 1. View is logical, it isn't stored in the physical medium. When we querying, view will be embed as subqueries in query statement. Therefore, modifying the definition of views is equivalent to modifying query_stmt which is defined in view.
  9. 2. query_stmt is arbitrarily supported SQL.

example

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