1.区分sql命令和sqlplus(oracle提供)-->sql不能缩写,sqlplus能够java
2.mysql 不区分字符串的大小写, oracle区分mysql
3.oracle 查询系统参数设置 : select * from v$nls_parameters;sql
alter session set parameter =' ';数据库
空值问题:session
(1)null !=null 数据库中null是未赋值的意思,不是表明空格或0oracle
(2)若是集合中含有null ,不能使用 not in 但能够使用in 函数
如: select * from emp where deptno not in(10,20,null)-->错误性能
(3)组函数会自动滤空,能够嵌套滤空函数来屏蔽.net
如:comm中含有10个空值3d
count(*)为15行记录
count(comm)为5行记录(已经滤空值)
4.查询带有下滑线的名字-->select * from table where name like '%\_%' escape '\' ;
5.desc 排序只做用于 最近的一列
6.排序时null在最后 select * from table order by comm desc nulls last(只能在oracle中)
7.ROUND--> 四舍五入 TRUNC截断 MOD求余
8:条件表达式
在sql语句中使用IF-THEN-ELSE逻辑
使用两种方法:
CASE表达式:SQL99的语法,相似basic ,比较繁琐
select ename,job,sal 涨前,
case job when 'PRESIDENT' then sal+1000
when 'MANAGER' then sal+800
else sal+400
end 涨后
from emp;
DECODE函数:Oracle本身的语法,相似java,比较简洁
select ename,job,sal 涨前,
decode(job,'PRESIDENT',sal+1000,
'MANAGER',sal+800,
sal+400) 涨后
from emp
9:where 和having的区别-->where 条件中不能有组函数
10:group by 语句的加强
group by deptno , job
+group by deptno
+group by null
=
group by rollup(deptno,job)
抽象:
group by rollup(a,b) = group by a,b
+group by a
+group by null
11:笛卡尔全集:两张 表的列数相加行数相成,应该尽可能使用链接条件,避免使用笛卡尔全集,由于笛卡尔全集中 可能有错误
13:注意,自链接有性能问题(所产生的笛卡尔集是表记录的平方,若是有1亿条记录,呵呵~)
14:层次查询,当你查询的数据是一颗树的时候,使用层次查询取代自链接
(1)伪列表示节点深度(能够不写)
select level , empno, ename, mgr
from emp
connect by prior empno=mgr
start with mgr is null (根节点)
order by empno
/
15
16:
17:
18:
19: