MySQL-DUAL

今天看到有人用DUAL表。了解了一下。
官方文档就解释的很好了:

You are permitted to specify DUAL as a dummy table name in situations where no tables are referenced:

不知道涉及哪个表的时候,可以指定DUAL作为一个假的表名:

mysql> SELECT 1 + 1 FROM DUAL;
        -> 2

DUAL is purely for the convenience of people who require that all SELECT statements should have FROM and possibly other clauses. MySQL may ignore the clauses. MySQL does not require FROM DUAL if no tables are referenced.

DUAL单纯为了方便声明了SELECT,需要使用FROM或者其他子句的时候。MySQL可能忽略这些子句。如果没有指定表,MySQL不需要FROM DUAL

你可能感兴趣的:(MySQL-DUAL)