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;