https://www.cnblogs.com/chuangege/p/6258658.html
转载地址见上方:
字符函数
concat(str1,str2)
字符串拼接函数
instr(x,find_string[,start][,occurrence])
返回指定字符串在某字符串中的位置,可以指定搜索的开始位置和返回第几次搜索出来的结果
length(str)
返回表达式中的字符数
replace(x,search_string,replace_string)
从字符串x中搜索search_string字符串,并使用replace_string字符串替换。并不会修改数据库中原始值
substr(x,start[,length])
返回字符串中的指定的字符,这些字符从字符串的第start个位置开始,长度为length个字符;如果start是负数,则从x字符串的末尾开始算起;如果length省略,则将返回一直到字符串末尾的所有字符
数值函数
ceil(value)
返回大于等于value的最小整数
floor(value)
返回小于等于value的最大整数
trunc(value,n)
对value进行截断,如果n>0,保留n位小数;n<0,则保留-n位整数位;n=0,则去掉小数部分
round(value,n)
对value进行四舍五入,保存小数点右侧的n位。如果n省略的话,相当于n=0的情况
注意:1.trunc和round用法类似,只不过trunc是硬生生截取,并不进行四舍五入,而round进行截取时四舍五入
2.都还可以对日期的截取,可以参考写的日期函数笔记
select trunc(555.666,-2) from dual;--返回结果为500
select round(555.666,-2) from dual;--返回结果为600
转换函数
to_char(x[,format]):将x转化为字符串。 format为转换的格式,可以为数字格式或日期格式
eg: select to_char('12345.67','99,999.99') from dual; --返回结果为12,345.67
to_number(x [, format]):将x转换为数字。可以指定format格式
eg: select to_number('-$12,345.67', '$99,999.99') from dual;
cast(x as type):将x转换为指定的兼容的数据库类型
eg: select cast(12345.67 as varchar2(10)),cast('05-7月-07' as date), cast(12345.678 as number(10,2)) from dual;
to_date(x [,format]):将x字符串转换为日期
eg: select to_date('2012-3-15','YYYY-MM-DD') from dual