花了点时间 复习、了一下字符串函数 希望对初学者有帮助
----------连接字符串函数-----------------
select concat('leiyi','hubei') from dual;
-------------------------查找leiyi的位置并替换成后面的字符串---------------
select translate('woshileiyi','leiyi','zhans') from dual;
----------------------------全部替换函数-------------
select REPLACE('JACK and JUE','J','BL') from dual;
------------------------大小写转换
select upper('zhanghsan') from dual;
select lower('ZHANGSHAN') from dual;
--------------字符串截取 beginposition lenght
select SUBSTR('ABCDEFG',3,4) from dual;
select substr('zhangshan',6,4) from dual;
------------查找字符串出现的位置
select INSTR('zhangshan','sh') from dual;
-------截取出字符中含有,的字符后面的字符串
select SUBSTR('11111,2222222',instr('11111,2222222',',')+1) from dual;
--------------decode函数的用法 -------
/*
decode(字段或字段的运算,值1,值2,值3)
这个函数运行的结果是,当字段或字段的运算的值等于值1时,该函数返回值2,否则返回值3
当然值1,值2,值3也可以是表达式,这个函数使得某些sql语句简单了许多
*/
select decode('china','china','中国人','我','China','外星人') from dual;
----------------计算字符串的长度
select LENGTH('BLAKE') from dual;
----------------