Tto create the view in Mysql
mysql>CREATE VIEW test.v AS SELECT * FROM t;mysql>
--------------
ex: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;
mysql>SELECT * FROM v;
+------+-------+-------+
| qty | price | value |
+------+-------+-------+
| 3 | 50 | 150 |
+------+-------+-------+
A view definition is subject to the following restrictions:
The
SELECTstatement cannot contain a subquery in theFROMclause.The
SELECTstatement cannot refer to system or user variables.The
SELECTstatement cannot refer to prepared statement parameters.Within a stored routine, the definition cannot refer to routine parameters or local variables.
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
CHECK TABLEstatement.The definition cannot refer to a
TEMPORARYtable, and you cannot create aTEMPORARYview.The tables named in the view definition must already exist.
You cannot associate a trigger with a view.
No comments:
Post a Comment