oracle函数笔记
其他
2020-04-10 13:44:46
阅读次数: 0
1.字符串操作函数
字符串操作函数
函数名 |
说明 |
char(88) |
返回指定数值的ascii码 |
concat(s2,s2) |
拼接字符串 |
initcap(s1) |
首字母转大写,其余小写 |
lower('ABC');upper('abc') |
大小写转换 |
lpad(s1,lenth,char),rpad(..) |
填充
|
ltrim(s1,char),rtrim(..) |
删除遇到的第一个char |
replace(s1,s2,s3) |
使用s3替换s1中的所有s2 |
substr(s1,start_pos,len) |
从起点开始截取len各字符长度,0与1都表示字符头位置 |
length(s1) |
计算字符长度 |
2.数值操作
数值操作函数
函数名 |
说明 |
abs(num) |
取绝对值 |
ceil(num),floor(num) |
上下取整 |
power(num1,num2) |
num1的num2次方 |
round(num,len) |
保留len位小数,四舍五入的方式 |
mod(num1,num2) |
取余 |
trunc(num,len) |
截取len位小数位数 |
3.日期操作
日期操作函数
函数 |
说明 |
add_months(date,num) |
指定日期增加月份,减去月份用负数 |
last_day(date) |
返回所在月份的最后一天 |
months_between(date1,date2) |
返回两个时间的间隔 |
next_day(date,'day') |
返回当前日期的下一个day,day与系统相关,如是中文环境,比如:‘星期一’ |
last_day(date) |
返回某个日期的最后一天 |
sysdate |
当前系统日期 |
current_timestamp |
当前日期的时间戳 |
round(date,'域') |
对日期的四舍五入,域 是 日期的域 |
trink(date,'域') |
对日期截取域 |
4.类型转换操作
类型转换函数
函数 |
说明 |
to_char(date,scope) |
将日期转为字符串,格式为字符 |
备注: extract(scope from date) |
从日期中提取域,格式为日期 |
to_char(num,type) |
将数字转为字符 |
to_date(date_char,type) |
将字符串转为 日期格式 |
to_number(num_char,type) |
将字符串转为特定格式的数字 |
5.正则表达式操作
正则表达式操作
函数 |
说明 |
regexp_like(str,pattern,scope) |
与like类似,scope包括:i,c,n,m,x 各自作用详见百度 |
regexp_substr(str,pattern) |
截取匹配组 |
regexp_instr(str,pattern) |
找到第一个匹配正则规则的位置 |
regexp_replace(str,pattern,str1) |
替换匹配组 |
发布了340 篇原创文章 ·
获赞 159 ·
访问量 13万+
转载自blog.csdn.net/qq_36285943/article/details/105427883