Oracle 5.0 Reference Manual page 1072

Table of Contents

Advertisement

mysql>
SELECT * FROM v;
+------+-------+-------+
| qty
| price | value |
+------+-------+-------+
|
3 |
50 |
150 |
+------+-------+-------+
A view definition is subject to the following restrictions:
• The
statement cannot contain a subquery in the
SELECT
• The
statement cannot refer to system or user variables.
SELECT
• Within a stored program, the definition cannot refer to program parameters or local variables.
• The
statement cannot refer to prepared statement parameters.
SELECT
• Any table or view referred to in the definition must exist. However, after a view has been created, it is
possible to drop a table or view that the definition refers to. In this case, use of the view results in an
error. To check a view definition for problems of this kind, use the
• The definition cannot refer to a
• Any tables named in the view definition must exist at definition time.
• You cannot associate a trigger with a view.
• As of MySQL 5.0.52, aliases for column names in the
maximum column length of 64 characters (not the maximum alias length of 256 characters).
is permitted in a view definition, but it is ignored if you select from a view using a statement
ORDER BY
that has its own
ORDER
For other options or clauses in the definition, they are added to the options or clauses of the statement
that references the view, but the effect is undefined. For example, if a view definition includes a
clause, and you select from the view using a statement that has its own
LIMIT
undefined which limit applies. This same principle applies to options such as ALL, DISTINCT, or
that follow the
SQL_SMALL_RESULT
MODE, and PROCEDURE.
LOCK IN SHARE
If you create a view and then change the query processing environment by changing system variables,
that may affect the results that you get from the view:
mysql>
CREATE VIEW v (mycol) AS SELECT 'abc';
Query OK, 0 rows affected (0.01 sec)
mysql>
SET sql_mode = '';
Query OK, 0 rows affected (0.00 sec)
mysql>
SELECT "mycol" FROM v;
+-------+
| mycol |
+-------+
| mycol |
+-------+
1 row in set (0.01 sec)
mysql>
SET sql_mode = 'ANSI_QUOTES';
Query OK, 0 rows affected (0.00 sec)
mysql>
SELECT "mycol" FROM v;
+-------+
| mycol |
+-------+
| abc
|
+-------+
1 row in set (0.00 sec)
CREATE VIEW
table, and you cannot create a
TEMPORARY
BY.
keyword, and to clauses such as INTO,
SELECT
1052
Syntax
clause.
FROM
CHECK TABLE
statement are checked against the
SELECT
statement.
view.
TEMPORARY
clause, it is
LIMIT
FOR
UPDATE,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents