Chapter 19. Views

MySQL 5.0

Chapter 19. Views

Views (including updatable views) are implemented in MySQL Server 5.0. Views are available in binary releases from 5.0.1 and up.

This chapter discusses the following topics:

  • Creating or altering views with or

  • Destroying views with

Discussion of restrictions on use of views is given in Section I.4, “Restrictions on Views”.

To use views if you have upgraded to MySQL 5.0.1 from an older release, you should upgrade your grant tables so that they contain the view-related privileges. See Section 5.6.2, “mysql_upgrade — Check Tables for MySQL Upgrade”.

Metadata about views can be obtained from the table and by using the statement. See Section 20.15, “The Table”, and Section 13.5.4.7, “ Syntax”.

19.1. ALTER VIEW Syntax

ALTER
    [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
    [DEFINER = {  | CURRENT_USER }]
    [SQL SECURITY { DEFINER | INVOKER }]
    VIEW  [()]
    AS 
    [WITH [CASCADED | LOCAL] CHECK OPTION]

This statement changes the definition of an existing view. The syntax is similar to that for . See Section 19.2, “ Syntax”. This statement requires the and privileges for the view, and some privilege for each column referred to in the statement.

This statement was added in MySQL 5.0.1. The and clauses may be used as of MySQL 5.0.16 to specify the security context to be used when checking access privileges at view invocation time. For details, see Section 19.2, “ Syntax”.