一、
(1)判断相等
== 改成 =
(2)变量赋值
= 改成 :=
(3)字符串和字符串拼接
"abc" 改成 'abc' -- 用单引号
'ab' + 'c' 改成 'ab' || 'c' 或 concat('ab', 'c')
(4)运算符顺序
() > not > and > or
(5)dba_xxx > all_xxx > user_xxx -- 全部 > (自己+他人给的) > 确实自己的
oracle系统的东西都是大写,记得加upper()。select * from all_tables where table_name = upper('dual')
二、
1.if else
if(xxx) {yyy;} else {zzz;}
改成
(1)
if (xxx) then
yyy;
else
zzz;
end if;
(2)
if (xxx) then yyy;
elsif (xxx2) then yyy2;
elsif (xxx3) then yyy3;
else zzz;
end if;
2.涉及null的判断相等
null与任何数判断都是false,null跟null也是false
-- not in
原因:not in 相当于 转为多个 != 判断
select * from dual where dummy not in ('A',null)
-- 等于
select * from dual where dummy != 'A' and dummy != null
3.rownum 与 order by 不能在同一层语句,以及rownum在where中的注意点
(1)rownum一定要有一个1
(2)涉及rownum的条件会影响rownum的生成,如:where mod(rownum,2) = 1。也是跟rownum的生成特性有关
(3)生成rownum值后,才会进行order by