1. 包含空值的表达式都为空
例: select a,b,a*12,a*12+b from test 若 a 为 null, 则 a*12 和 a*12+b 为 null, 若 b 为 null, 则 a*12+b 也为 null.
nvl 和 nvl2 滤空函数, nvl(a,b) 判断 a 是否为 Null, 如果为 null, 返回 b, 否则返回 a;nvl2(a,b,c) 判断 a 是否为 null, 如果为 null, 返回 c, 不为 null 返回 b.
2.null 永远不 = null, 判断一个值是否为 null. 应该用 is null 或者 is not null
例子: select * from emp where a=null 执行失败
3.oracle 连接符 || 相当于 java 中对 String 的相加
例子: select 'Hello'||'World' from dual;
dual 为 oracle 中内置的伪表. oracle 中 from 后必须跟随一张表名, 若 select 属性不跟任何表相关, 则使用 from dual;
4.oracle 中大小写敏感, mysql 中大小写不敏感.
例子: select * from emp where a="King" 和 select * from emp where a = "KING" 的结果是不一样的, 而在 mysql 中结果相同.
5.oracle 中日期格式敏感. where 中日期过滤条件必须符合预定义的日期格式. 默认的格式是 DD-MON-RR
6.between .. and .. 包含边界, 小值在前, 大值在后.
7. 如果集合中有 null 值, 不能使用 not in, 可以使用 in
例子: select * from emp where deptno not in(10,20,null); 查询不出数据
8. 模糊查询转义字符的例子
例子: select * from emp where ename like '%\_%' escape '\'
9.oracle 的事务是自动开启的, mysql 的事务手动开启
10.where 语句的解析顺序是从右往左的
例子: where condition1 and condition2; 先执行 condition2.
尽量把容易 false 的语句写在后面, 效率更高.
11.order by 后面可以跟列名, 表达式, 别名, 序号
例子: order by sal;order by sal*12;order by 年薪; order by 4;
12.order by 排序时, 如果排序的列有 null 值, 默认 null 显示在后面, oracle 中 null 值最大
例子: order by conn desc nulls last;
如果不加 nulls last,conn 为 null 的记录为显示在最上方, 加上 nulls last, 含有 null 值的记录便会出现在最下方
来源: http://www.bubuko.com/infodetail-2689489.html