标签:
--lower()全部小写
select lower(‘Nice‘) from dual;
--upper()全部大写
select upper(‘Nice‘) from dual;
--initcap()首字母大写
select initcap(‘nice‘) from dual;
--concat()嵌套字符串
select concat(‘Very‘,‘Nice‘) from dual;
--substr()截取的字符串
select substr(‘Nice‘,2) from dual;
--length()字符个数统计/lengthb()字节个数统计
select length(‘Nice‘) as 字符数,lengthb(‘Nice‘) as 字节数 from dual;
--instr(‘大字符串‘,‘小字符串‘)返回小字符串在大字符串中出现的位置
select instr(‘Nice‘,‘c‘) from dual;
--trim()01.去除开头和结尾的空格
select trim(‘ Nice ‘) from dual;
--trim()02.去除前面单个字符
select trim(leading ‘N‘ from ‘Nice‘) from dual;
--trim()03.去除后面单个字符
select trim(trailing ‘e‘ from ‘Nice‘) from dual;
--trim()04.去除前后面单个字符
select trim(both ‘N‘ from ‘NiceN‘) from dual;
--months_between()两个日期相差的月数
select months_between
(to_date(‘02-02-1995‘,‘MM-DD-YYYY‘),
to_date(‘01-01-1995‘,‘MM-DD-YYYY‘)) "months"
from dual;
--add_months()向指定日期中加上若干月数
select add_months(sysdate,6) from dual;
--floor()两个日期间的天数
select floor(sysdate-to_date(‘20160825‘,‘yyyymmdd‘)) from dual;
--months_between()两个日期间相差的月数
select months_between(sysdate,to_date(‘20160720‘,‘yyyymmdd‘)) from dual;
--隐式转换
select * from emp
where hiredate=‘17-12月-80‘
--显示转换to_char()对日期的转换
select to_char(‘sysdate‘,‘yyyy-mm-dd hh24:mi:ss‘) from dual;
--round()四舍五入
select round(12.45,1) from dual;
--trunc()截断
select trunc(15.79,1) "Num" from dual;
--nvl()和nvl2() 滤空函数
select sal*12工资,comm 奖金,sal*12+nvl(comm,0) from emp;
select sal*12工资,comm 奖金,sal*12+nvl2(comm,comm,0) from emp;
--decode()
标签:
原文地址:http://www.cnblogs.com/qingzhi/p/5811233.html