CREATE VIEW Statement 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; mysql>  SELECT * FROM v; +------+-------+-------+ | qty | price | value | +------+-------+-------+ | 3 | 50 | 150 | +------+-------+-------+ A view definition is subject to the following restrictions: ORDER BY  is permitted in a view definition, but it is ignored if you select from a view using a statement that has its own  ORDER BY . 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  LIMIT  clause, and you select from the view using a statement that has its own  LIMIT  clause, it is undefined which limit applies. This same principle applies to options such as  ALL ,  DISTINCT , or  SQL_SMALL_RESULT  that follow the  SELECT  keyword, and to clauses such as  INTO ,  FOR UPDATE ,  FOR SHARE ,  LOCK IN SHARE MODE , and  PROCEDURE . The results obtained from a view may be affected if you change the query processing environment by changing system variables: 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) 2608 •The  SELECT  statement cannot refer to system variables or user-defined variables. •Within a stored program, the  SELECT  statement cannot refer to program parameters or local variables. •The  SELECT  statement cannot refer to prepared statement parameters. •Any table or view referred to in the definition must exist. If, after the view has been created, a table or view that the definition refers to is dropped, use of the view results in an error. To check a view definition for problems of this kind, use the  CHECK TABLE  statement. •The definition cannot refer to a  TEMPORARY  table, and you cannot create a  TEMPORARY  view. •You cannot associate a trigger with a view. •Aliases for column names in the  SELECT  statement are checked against the maximum column length of 64 characters (not the maximum alias length of 256 characters).