--绝对值
select abs(-100) from dual;
--取余
select mod(8,3) from dual;
--取整,大于该数的最小整数(上限值)
select ceil(12.0) from dual;
select ceil(12.5) from dual;
--取整,小于该数的最大整数(下限值)
select floor(12.5) from dual;
--四舍五入,选择需要保留的小数位
select round(12.456,0) from dual;
--截取小数,输入需要保留的小数位数,最多保留最大长度,也可取整
select trunc(12.456,1) from dual;
--截取长度
select length(‘abcdefg‘) from dual;
select xingm,length(xingm) from t_hq_ryxx;
--截取字符串,第1个数为截取位置,正数从做开始算,负数从右边开始算,第二个数为截取长度,截取位置超过字符长度的为空
select xingm,substr(xingm,0,1) from t_hq_ryxx;
--字符串连接
select concat(‘ab‘,concat (‘cd‘,‘efg‘)) from dual;
select ‘ab‘ || ‘cd‘ || ‘efg‘ from dual;
--查找,可以指定起始位置
select instr(‘abcdefg‘,‘d‘) from dual;
select instr(‘adcdefg‘,‘d‘,1) from dual;
select instr(‘abcdefg‘,‘h‘) from dual;
--转换大小写,首字母转换大写
select upper(‘assa‘),lower(‘ASDF‘) from dual;
select upper(‘assa‘),lower(‘ASDF‘), initcap(‘this is a test‘) from dual;
--替换
select replace(‘abcdefg‘,‘ab‘,‘123‘) from dual;
--update t_hq_ryxx set xingm = replace(xingm,‘额‘,‘阿‘) where xingm like ‘额%‘;
--填充,没有的用空格填充,从往有填充,往左填充
select rpad(‘aa‘,8,‘c‘) from dual;
select lpad(‘aa‘,8) from dual;
--去空格
select trim (‘ abcde ‘) from dual;
--去右边的空格
select rtrim (‘ abcde ‘) from dual;
--去首部字符
select trim (leading ‘a‘ from ‘aabcde ‘) from dual;
--去后部字符
select trim (trailing ‘a‘ from ‘aabcdea‘) from dual;
--去前后字符
select trim (both ‘a‘ from ‘aabacdea‘) from dual;
--当前系统时间
select sysdate from dual;
--修改当前月份
select add_months(sysdate,-2) from dual;
--取月份的最后一天,修改天数
select last_day(sysdate)+1 from dual;
--转换函数
select cast(‘123‘ as number) +123 from dual;
select cast(123 as varchar2(3)) + 147 from dual;
select ‘123‘ +123 from dual;
select to_char(sysdate,‘yy-dd-mm‘) from dual;
select to_char(sysdate,‘yyyy-dd-mm hh24:mi:ss‘) from dual;
--四舍五入
select to_char(123.456,‘999.9‘) from dual;
--转换日期
select to_date(‘2015-12-23 04:13:25‘,‘yyyy-mm-dd hh24:mi:ss‘) +1 from dual;
update t_hq_ryxx set ruzrq = to_date(‘24-10-2015‘,‘dd-mm-yyyy‘) where bianh = 107;
select * from t_hq_ryxx where ruzrq > to_date(‘2015-10-22‘,‘yyyy-mm-dd‘);
--转换数字格式
select to_number(‘123.456‘,‘999.999‘) from dual;
--null函数
--select nvl(nianl,54) from t_hq_ryxx;
--非空的替换成20,空值为1000
--select nvl2(nianl,20,1000) from t_hq_ryxx;
--空值替换成0
--select nvl(nianl,0) + gongz from t_hq_ryxx
--提出符合条件的内容
select * from t_hq_ryxx where lnnvl(nianl > 20);
原文:http://www.cnblogs.com/shadowduke/p/4922037.html