Oracle-运算符not and or顺序

执行顺序:not > and > or

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-- 情况1:
select id from dual d
where d.id = '0001'
or d.id = '0002'
and d.count > 900;
-- 结果:将后两个条件合并,在于条件1取或,即:如下图。
select id from dual d
where d.id = '0001'
or (d.id = '0002'
and d.count > 900);

-- 情况2:
select id from dual d
where (d.id = '0001'
or d.id = '0002')
and d.count > 900;
-- 结果:将前两个条件合并取或,再与条件3取并集。