Oracle 5.0 Reference Manual page 1723

Table of Contents

Advertisement

CREATE VIEW v AS SELECT col1, 1 AS col2 FROM t;
This view is not insertable because
update does not try to update col2. This update is permissible:
UPDATE v SET col1 = 0;
This update is not permissible because it attempts to update a derived column:
UPDATE v SET col2 = 0;
It is sometimes possible for a multiple-table view to be updatable, assuming that it can be processed
with the
algorithm. For this to work, the view must use an inner join (not an outer join or a
MERGE
UNION). Also, only a single table in the view definition can be updated, so the
only columns from one of the tables in the view. Views that use
though they might be theoretically updatable, because the implementation uses temporary tables to
process them.
For a multiple-table updatable view,
supported.
is not supported for views.
INSERT DELAYED
If a table contains an
AUTO_INCREMENT
table that does not include the
[961], because the side effects of inserting default values into columns not part
LAST_INSERT_ID()
of the view should not be visible.
The
WITH CHECK OPTION
rows except those for which the
In a
WITH CHECK OPTION
determine the scope of check testing when the view is defined in terms of another view. The
keyword restricts the
CHECK OPTION
for underlying views to be evaluated as well. When neither keyword is given, the default is CASCADED.
Consider the definitions for the following table and set of views:
mysql>
CREATE TABLE t1 (a INT);
mysql>
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a < 2
->
WITH CHECK OPTION;
mysql>
CREATE VIEW v2 AS SELECT * FROM v1 WHERE a > 0
->
WITH LOCAL CHECK OPTION;
mysql>
CREATE VIEW v3 AS SELECT * FROM v1 WHERE a > 0
->
WITH CASCADED CHECK OPTION;
Here the
and
views are defined in terms of another view, v1.
v2
v3
so inserts are tested only against the
tested not only against its own check, but against those of underlying views. The following statements
illustrate these differences:
mysql>
INSERT INTO v2 VALUES (2);
Query OK, 1 row affected (0.00 sec)
mysql>
INSERT INTO v3 VALUES (2);
ERROR 1369 (HY000): CHECK OPTION failed 'test.v3'
MySQL sets a flag, called the view updatability flag, at
(true) if
and
UPDATE
DELETE
to
(false). The
NO
IS_UPDATABLE
status of this flag. It means that the server always knows whether a view is updatable. If the view is
not updatable, statements such UPDATE, DELETE, and
that even if a view is updatable, it might not be possible to insert into it, as described elsewhere in this
section.)
The updatability of views may be affected by the value of the
system variable. See
Section 5.1.4, "Server System
Updatable and Insertable Views
is derived from an expression. But it is updatable if the
col2
can work if it inserts into a single table.
INSERT
column, inserting into an insertable view on the
column does not change the value of
AUTO_INCREMENT
clause can be given for an updatable view to prevent inserts or updates to
clause in the
WHERE
clause for an updatable view, the
only to the view being defined.
check.
v2
v3
(and similar operations) are legal for the view. Otherwise, the flag is set
column in the
INFORMATION_SCHEMA.VIEWS
1703
UNION ALL
select_statement
and
LOCAL
CASCADED
CASCADED
has a
v2
has a
check option, so inserts are
CASCADED
time. The flag is set to
CREATE VIEW
are illegal and will be rejected. (Note
INSERT
updatable_views_with_limit
Variables".
clause must name
SET
are not permitted even
is not
DELETE
is true.
keywords
LOCAL
causes the checks
check option,
LOCAL
YES
table displays the
[504]

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents