2

SQL Views for MySQL的功能是否有任何限制?

例如:您可以使用“JOIN”命令创建表视图吗?

4

6 回答 6

6

You should read Restrictions on Views for details on view limitations.

于 2010-01-14T17:14:49.217 回答
0

MySQL allows JOIN commands

MySQL Create View syntax

于 2010-01-14T17:10:26.323 回答
0

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.

于 2010-01-14T17:13:16.483 回答
0

Short answer - yes. In two words view just named select (without order by of course).

于 2010-01-14T17:15:27.620 回答
0

与 SQL 中的所有其他内容一样,语法、功能和可能性取决于您正在使用的数据库管理系统。但是加入表格是非常基本的东西。没有它,视图就没有多大用处。

于 2010-01-14T17:18:53.853 回答
0
  1. 临时表:

    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'
    
  2. 系统和本地变量:

    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
    
  3. 子查询:

    CREATE OR REPLACE view cat AS SELECT * FROm SELECT * FROM super;
    ERROR 1349 (HY000): View's SELECT contains a subquery in the FROM clause
    
于 2015-06-17T05:18:28.503 回答