Oracle 常用内置函数

 1 --绝对值
 2 select abs(-134) from dual;--134
 3 --求模
 4 select mod(123,10) from dual;--3
 5 --取整
 6 select ceil(123.33) from dual;--124
 7 select floor(123.33)from dual;--123
 8 --四舍五入
 9 select round(123.45)from dual;--123
10 select round(123.45,1)from dual;--123.5
11 select round(126.45,-1)from dual;--130
12 --截取
13 select trunc(123.45)from dual;--123
14 select trunc(123.45,1)from dual;--123.4
15 select trunc(126.45,-1)from dual;--120
16 
17 --字符串长度
18 select length('一个字符串')from dual;--5
19 --截取
20 select st.sname,substr(st.sname,) from student st;
21 --替换
22 select replace('abcde','b')from dual;--acde
23 select replace('abcde','b','B')from dual;--aBcde
24 --去空格
25 select trim('  abcde  ')from dual;
26 select Ltrim('  abcde  ')from dual;--去左空格
27 select Rtrim('  abcde  ')from dual;--去右空格
28 --查找字符串
29 select instr('abcdeabcd','b')from dual;--找到返回第一个位置值 ,找不到返回0
30 
31 --系统当前时间
32 select sysdate from dual;
33 --运算
34 select sysdate + 10 from dual;--当前日期天数增加10
35 select sysdate - 30 from dual;--2016/5/16/15:06:02
36 --加月份
37 select add_months(sysdate,1)from dual;--当前月份加1
38 --月的最后一天
39 select last_day(to_date('2016/5/16','yyyy/mm/dd'))from dual;--查询月份的最后一天是几号
40 
41 --当前时间转成字符串
42 select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;--2016-06-15
43 select to_date('2016/5/16','yyyy/mm/dd')from dual;
44 select * from student st where st.sbirthday > to_date('19720101','yyyymmdd');
45 select to_number('2016.6')from dual;

 

posted @ 2016-06-15 15:56  唐枫  阅读(394)  评论(0编辑  收藏  举报