前言:最近工作中从mysql数据库切换到oracle,写sql语句时就稍微复杂了那么一丢丢,想着怎么样才能写出执行效率高的sql,也就是面试中面试官常问的sql优化。那么想要优化sql你就得先知道到sql语句的执行顺序以及执行效率。
sql执行顺序
mysql执行顺序
from
join
on
where
group by
avg()等聚合函数
having
select
distinct
order by
limit
oracle执行顺序
oracle执行顺序
(8)select
(9)distinct (11)
(1)from
(3)join
(2)on
(4)where
(5)group by
(6)with {cube | rollup}
(7)having
(10)order by