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);- select lower(ename) from emp;
- select upper(substr(ename,1,1))
||lower(substr(ename,2,length(ename))) from emp- select substr(ename,1,3) from emp;
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 * from emp
where sysdate>add_months(hiredate,8);- select ename,trunc(sysdate-hiredate)
"入职天数" from emp;- SELECT HIREDATE, ENAME FROM EMP WHERE
LAST_DAY(HIREDATE)-2=HIREDATE
Oracle转换函数
- TO_CHAR
- SQL> SELECT ENAME, TO_CHAR(HIREDATE,'YYYY/MM/DD hh24:mi:ss')
- , TO_CHAR(SAL,'L99999.99') FROM EMP;
- SQL> SELECT ENAME,HIREDATE FROM EMP WHERE TO_CHAR(HIREDATE,'
- YYYY')=1988;
- SQL> SELECT ENAME,HIREDATE FROM EMP WHERE TO_CHAR(HIREDATE,'
- YYYY-MM')='1988-12';
Oracle系统函数:
- TERMINAL:
- LANGUAGE:
- DB_NAME:
- NLS_DATE_FORMAT:
- SESSION_USER:
- SELECT SYS_CONTEXT('USERENV','LANGUAGE') FROM DUAL;
- SELECT SYS_CONTEXT('USERENV','SESSION_USER') FROM DUAL;
以上的相关内容就是对Oracle函数多种的分类的介绍,望你能有所收获。
【编辑推荐】