SQL Views for MySQL的功能是否有任何限制?
例如:您可以使用“JOIN”命令创建表视图吗?
You should read Restrictions on Views for details on view limitations.
MySQL allows JOIN commands
Regarding JOIN, yes:
mysql> create table foo (i int);
Query OK, 0 rows affected (0.03 sec)
mysql> create table bar (i int);
Query OK, 0 rows affected (0.03 sec)
mysql> create view foobar as select foo.i as foo_i, bar.i as bar_i from foo join bar on (foo.i=bar.i);
Query OK, 0 rows affected (0.02 sec)
But as others answers pointed, the manual is a great resource.
Short answer - yes. In two words view just named select (without order by of course).
与 SQL 中的所有其他内容一样,语法、功能和可能性取决于您正在使用的数据库管理系统。但是加入表格是非常基本的东西。没有它,视图就没有多大用处。
临时表:
CREATE TEMPORARY TABLE super (id int);
mysql> CREATE OR REPLACE view cat AS SELECT * FROm super;
ERROR 1352 (HY000): View's SELECT refers to a temporary table 'super'
系统和本地变量:
mysql> SELECT @sosize;//1000
mysql> CREATE OR REPLACE view cat AS SELECT *,@sosize FROm super;
ERROR 1351 (HY000): View's SELECT contains a variable or parameter
子查询:
CREATE OR REPLACE view cat AS SELECT * FROm SELECT * FROM super;
ERROR 1349 (HY000): View's SELECT contains a subquery in the FROM clause