--绝对值 select abs(-100) from dual; --取余 select mod(8 ,3) from dual; --上限值 select ceil (12.5) from dual; --下限值 select floor (12.5) from dual; --四舍五入 select round (12.456,1) from dual; --(截)取整 select trunc (12.456,0) from dual; --字符串长度 select length (‘asdadad‘) from dual; select SNAME,length(SNAME) from T_HQ_STUDENT; select SNAME, substr(SNAME, 1, 2) from T_HQ_STUDENT; --第一个数字是起始位置,第二个数字是截取长度 --字符串连接 select concat(‘sa‘,‘sd‘) from dual; select concat(‘sa‘,concat(‘sa‘,‘sd‘)) from dual; select ‘sa‘||‘sad‘||‘sda‘ from dual; --查找字符串 select instr (‘asdfgh‘,‘d‘) from dual; select instr (‘asdfsdfdgdh‘,‘d‘,3) from dual; --大小写转换 select upper (‘assd‘), lower (‘DFFD‘) from dual; --upper 小写换大写;lower 大写换小写 select initcap (‘this is a test‘) from dual; --替换 select replace (‘asdfg‘,‘as‘,‘13‘) from dual; --填充 select lpad(‘as‘,5,‘d‘) from dual; --填充左边 select rpad(‘as‘,4,‘d‘) from dual; --填充右边 --删除 select trim(‘ asdfg ‘) from dual; --去空格 select ltrim (‘ asdfg ‘) from dual; --去左空格 select rtrim(‘ asdfg ‘) from dual; --去右空格 --删除字符 select trim (leading‘a‘ from ‘aasdsd‘) from dual; select trim (trailing‘a‘ from ‘aasdsda‘) from dual; select trim (both‘a‘ from ‘aasdsda‘) from dual; --当前时间 select sysdate from dual; --月份加减 select add_months(sysdate,2) from dual; select add_months(sysdate,-2) from dual; select last_day(sysdate) from dual; select last_day(sysdate)+ 10 from dual; --转换函数 select cast (‘123‘as number) + 123 from dual; select cast(1233 as varchar2(4)) from dual; select cast(1233 as varchar2(4)) + 123 from dual; select ‘123‘|| 123 from dual; select cast(sysdate as varchar2(20)) from dual; select to_char(sysdate,‘yyyy-mm-dd‘) from dual; select to_char(sysdate,‘yyyy-mm-dd HH24:mi:ss‘) from dual; select to_char(123.456, ‘999.99‘) from dual; --不常用 select to_date(‘2015-10-29‘,‘yyyy-mm-dd‘) from dual;
时间: 2024-10-06 06:18:18