简单oracle之常用函数

select round(10.38764, 3) round from dual;     --四舍五入。10.388
select trunc(10.38764, 3) trunc from dual;       --截断。10.387
select to_char(sysdate, 'yyyy-MM-dd hh24:mi:ss') to_char from dual;    --日期转字符。2016-02-26 18:07:35
select to_date('2000-1-1 18:18:18', 'yyyy-MM-dd hh24:mi:ss') to_date from dual;     --字符转日期。2000/1/1 18:18:18
select lower('ABC') lower from dual;    --大写转小写。abc
select upper('abc') upper from dual;    --小写转大写。ABC
select length('How long is this sentence') length from dual;   --字符长度。25
select last_day(trunc(sysdate)) last_day from dual;    --当月最后一天的日期。2016/2/29
select next_day(sysdate, 7) next_day from dual;    --当前日期的下一个星期六的时间,7代表星期六。2016/2/27 18:07:35
select to_number('12') to_number from dual;    --字符转数字。12
select decode('y', 'y', 'yes', 'n', 'no') decode from dual;    --判断,如果y等于y,返回yes,如果等于n,返回no。yes
select least(2, 8, 1, 3, 9) least from dual;    --最小数字。1
select greatest(2, 8, 1, 3, 9) greatest from dual;   --最大数字。9
select nvl('1', '2') nvl from dual;    --第一个参数不为null,返回第一个值,否侧返回第二个值。1
select concat('con', 'nect') concat from dual;    --连接字符串。connect
select abs(-6) abs from dual;   --绝对值。6
select cos(1) cos from dual;   --余弦。0.54030230586814
select sin(1) sin from dual;    --正弦。0.841470984807897
select acos(1) acos from dual;   --反余弦。0
select asin(1) asin from dual;   --反正弦。1.5707963267949
select tan(1) tan from dual;   --正切。1.5574077246549
select atan(1) atan from dual;  --反正切。0.785398163397448
select tanh(1) tanh from dual;   --双曲函数。0.761594155955765
select ln(0.7) ln from dual;     --对数。-0.356674943938732
select ceil(9.6) ceil from dual;   --大于9.6最小整数。10
select floor(9.6) floor from dual;     --小于9.6最大整数。9
select sqrt(9) sqrt from dual;     --平方根。3
select replace('a,b,c',',','') replace from dual;   --替换。abc
select replace(wm_concat(a.family_name),',','') wm_concat from  (select * from  (select '张' family_name from dual
union select '三丰' first_name from dual) t order by nlssort(t.family_name,'NLS_SORT=SCHINESE_PINYIN_M') desc) a;       --字段连接(附带replace用法,汉字排序,union用法)。张三丰
select ltrim('  abc') ltrim from dual;     --去掉左空格
select rtrim('abc   ') rtrim from dual;    --去掉右空格
select substr('abcdef',3,2) from dual;       --截取第n个字符开始,长度为m的字符串。cd
select add_months(trunc(sysdate),1) from dual;  -- 下一个月的日期。如果是-1,上一个月日期

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

简单就好-怒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值