============================================================================
主要用来分辨查询的类型,是普通查询还是联合查询还是子查询
1. sample: 简单的查询,不包含子查询和union
mysql> explain select * from emp;
- primary: 查询中若包含任何复杂的子查询,最外层查询则被标记为Primary
mysql> explain select * from emp e where e.deptno = (select d.deptno from dept d where d.dname = ‘SALES’);
- union: 在union,union all和子查询中的第二个和随后的select被标记为union
mysql> explain select * from emp where deptno = 10 union select * from emp where sal >2000;
4. dependent union: 在包含UNION或者UNION ALL的大查询中,如果各个小查询都依赖于外层查询的话,那除了最左边的那个小查询之外,其余的小查询的select_type的值就是DEPENDENT UNION。
mysql> explain select * from emp e where e.empno in ( select empno from emp where deptno = 10 union select empno from emp where sal >2000)
5. union result: 从union表获取结果的select。
mysql> explain select * from emp where deptno = 10 union select * from emp where sal >2000;
6. subquery: 在select或者where列表中包含子查询(不在from子句中)
mysql> explain select * from emp where sal > (select avg(sal) from emp) ;