Oracle 5.0 Reference Manual page 1071

Table of Contents

Advertisement

The
clause affects how MySQL processes the view. The
ALGORITHM
clauses specify the security context to be used when checking access privileges at view invocation
time. The
WITH CHECK OPTION
referenced by the view. These clauses are described later in this section.
The
statement requires the
CREATE VIEW
privilege for each column selected by the
statement you must have the
SELECT
you must also have the
[578]
privilege, depending on the
SUPER
When a view is referenced, privilege checking occurs as described later in this section.
A view belongs to a database. By default, a new view is created in the default database. To create the
view explicitly in a given database, specify the name as
mysql>
CREATE VIEW test.v AS SELECT * FROM t;
Within a database, base tables and views share the same namespace, so a base table and a view
cannot have the same name.
Columns retrieved by the
be expressions that use functions, constant values, operators, and so forth.
Views must have unique column names with no duplicates, just like base tables. By default, the
names of the columns retrieved by the
define explicit names for the view columns, the optional
of comma-separated identifiers. The number of names in
number of columns retrieved by the
Note
Prior to MySQL 5.0.72, when you modify an existing view, the server saves a
backup of the current view definition under the view database directory, in a
subdirectory named arc. The backup file for a view
If you alter the view again, the next backup is named v.frm-00002. The three
latest view backup definitions are stored.
Backed up view definitions are not preserved by mysqldump, or any other such
programs, but you can retain them using a file copy operation. However, they
are not needed for anything but to provide you with a backup of your previous
view definition.
It is safe to remove these backup definitions, but only while
running. If you delete the
an error occurs the next time you try to alter the view:
mysql> ALTER VIEW v AS SELECT * FROM t;
ERROR 6 (HY000): Error on delete of '.\test\arc/v.frm-0004' (Errcode:
2)
Unqualified table or view names in the
database. A view can refer to tables or views in other databases by qualifying the table or view name
with the proper database name.
A view can be created from many kinds of
views. It can use joins, UNION, and subqueries. The
following example defines a view that selects two columns from another table, as well as an expression
calculated from those columns:
mysql>
CREATE TABLE t (qty INT, price INT);
mysql>
INSERT INTO t VALUES(3, 50);
mysql>
CREATE VIEW v AS SELECT qty, price, qty*price AS value FROM t;
CREATE VIEW
clause can be given to constrain inserts or updates to rows in tables
CREATE VIEW
SELECT
SELECT
[577]
privilege for the view.
DROP
DEFINER
statement can be simple references to table columns. They can also
SELECT
SELECT
statement.
SELECT
arc
SELECT
SELECT
1051
Syntax
DEFINER
[577]
privilege for the view, and some
statement. For columns used elsewhere in the
[578]
privilege. If the
OR REPLACE
CREATE VIEW
value, as described later in this section.
db_name.view_name
statement are used for the view column names. To
column_list
column_list
subdirectory or its files while
statement are interpreted with respect to the default
statements. It can refer to base tables or other
need not even refer to any tables. The
SELECT
and
SQL SECURITY
clause is present,
might also require the
when you create it:
clause can be given as a list
must be the same as the
is named v.frm-00001.
v
is not
mysqld
is running,
mysqld

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents