替代函数 和java'中的replace差不多
select REPLACE('aaa,aaa', ',' ,'..') from dual
-----------------------------------------------------
1 aaa..aaa
select REPLACE('aaa,aaa', ',','') from dual
select REPLACE('aaa,aaa', ',') from dual
-----------------------------------------------------
1 aaaaaa
2.translate
--单字符替换 a替换成w b替换成c
select translate('abcdefbga','ab','wc')from dual;
-----------------------------------------------------
1 wccdefcgw
3.TRIM 去掉一个字段的开头和结尾的空格
TRIM(字段)
(1)distinct是去重后的结果集,而group by是按某项进行分组显示,两查询出来的结果都是默认升序的。
select *from emp
ID NAME PASSWORD
-------------------------
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 1 1
8 2 2
9 3 3
10 4 4
select distinct e.name,e.password as password from emp e
NAME PASSWORD
-----------------------
1 1
2 2
3 3
4 4
5 5
6 6
注:distinct 只能放在第一个字段
select e.name,sum(e.password) as password from emp e group by e.name
--select e.name from emp e group by e.name
NAME PASSWORD
-------------------------------
1 2
3 6
6 6
5 5
2 4
4 8
注:select 后面必须要跟聚合函数 因为后面的 group by会根据 e.name分组求sum(e.password)的和
1700W数据测试看不出效率区别