Oracle函数有很多种的分类,我们今天要向大家介绍的有Oracle字符函数、Oracle函数中的Oracle数学函数、还有Oracle日期函数以及Oracle转换函数的相关内容的介绍,望你会有所收获。
Oracle字符函数:
lower(char),upper(char),length(char),substr(char,m,n), replace(char1,search_string,replace_string), instr(str,char); selectlower(ename)fromemp; selectupper(substr(ename,1,1)) ||lower(substr(ename,2,length(ename)))fromemp selectsubstr(ename,1,3)fromemp;
select replace(ename,’A’,’我是老鼠’) from emp;
Oracle函数中的Oracle数学函数:
round(n,[m]),trunc(n,[m]),mod(m,n),floor(n),ceil(n);
Oracle日期函数
sysdate,add_months(hire_date,8); select*fromemp wheresysdate>add_months(hiredate,8); selectename,trunc(sysdate-hiredate) "入职天数"fromemp; SELECTHIREDATE,ENAMEFROMEMPWHERE LAST_DAY(HIREDATE)-2=HIREDATE
Oracle转换函数
TO_CHAR SQL>SELECTENAME,TO_CHAR(HIREDATE,'YYYY/MM/DDhh24:mi:ss') ,TO_CHAR(SAL,'L99999.99')FROMEMP; SQL>SELECTENAME,HIREDATEFROMEMPWHERETO_CHAR(HIREDATE,' YYYY')=1988; SQL>SELECTENAME,HIREDATEFROMEMPWHERETO_CHAR(HIREDATE,' YYYY-MM')='1988-12';
Oracle系统函数:
TERMINAL: LANGUAGE: DB_NAME: NLS_DATE_FORMAT: SESSION_USER: SELECTSYS_CONTEXT('USERENV','LANGUAGE')FROMDUAL; SELECTSYS_CONTEXT('USERENV','SESSION_USER')FROMDUAL;
相关文章
标签:Oracle