Views (including updatable views) are implemented in MySQL Server 5.0. Views are available in binary releases from 5.0.1 and up.
Answers to some frequently asked questions concerning views in MySQL 5.0 can be found in Section A.6, “MySQL 5.0 FAQ — Views”.
This chapter discusses the following topics:
Creating or altering views with CREATE VIEW
or ALTER VIEW
Destroying views with DROP VIEW
Discussion of restrictions on use of views is given in Section F.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 4.4.9, “mysql_upgrade — Check Tables for MySQL Upgrade”.
Metadata about views can be obtained from the
INFORMATION_SCHEMA.VIEWS table and by using the
SHOW CREATE VIEW statement. See
Section 21.15, “The INFORMATION_SCHEMA VIEWS Table”, and
Section 12.5.4.7, “SHOW CREATE VIEW Syntax”.
ALTER
[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
[DEFINER = { user | CURRENT_USER }]
[SQL SECURITY { DEFINER | INVOKER }]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
This statement changes the definition of a view, which must exist.
The syntax is similar to that for CREATE VIEW
and the effect is the same as for CREATE OR REPLACE
VIEW. See Section 20.2, “CREATE VIEW Syntax”. This statement
requires the CREATE VIEW and
DROP privileges for the view, and some
privilege for each column referred to in the
SELECT statement. As of MySQL 5.0.52,
ALTER VIEW is allowed only to the original
definer or users with the SUPER privilege.
This statement was added in MySQL 5.0.1. The
DEFINER and SQL SECURITY
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 20.2, “CREATE VIEW Syntax”.