转自https://blog.csdn.net/weixin_44145478/article/details/107079176
mysql文档中对于dual表的解释:
You are allowed to specify DUAL as a dummy table name in situations
where no tables are referenced: 你可以在没有表的情况下指定一个虚拟的表名 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不需要从DUAL。
1 select 7*9 fromdual; 计算器2 SELECT SYSDATE() from dual 获取系统时间
案例
开发过程中,需要对数据进行excel展示或导出,并且需要各种类型的数据,这里提供一种通过dual表来实现
创建表teacher,插入数据<