oracle常用函數(shù)匯總(分享)建站知識
導讀:1建站知識以下是對oracle中的常用函數(shù)進行了匯總介紹,需要的朋友可以過來參考下seo網(wǎng)站關(guān)鍵詞優(yōu)化網(wǎng)站seo優(yōu)化軟件。
一、運算符算術(shù)運算符:+ - * / 可以在select 語句中使用連接運算符:|| select deptno|| dname from dept; 比較運算符:> >= = != < <= like between is null in邏輯運算符:not and or 集合運算符: intersect ,union, union all, minus 要求:對應集合的列數(shù)和數(shù)據(jù)類型相同 查詢中不能包含long 列 列的標簽是第一個集合的標簽 使用order by時,必須使用位置序號,不能使用列名例:集合運算符的使用:
復制代碼 代碼如下:
intersect ,union, union all, minus select * from emp intersect select * from emp where deptno=10 ;select * from emp minus select * from emp where deptno=10;select * from emp where deptno=10 union select * from emp where deptno in (10,20); --不包括重復行 select * from emp where deptno=10 union all select * from emp where deptno in (10,20); --包括重復行
二.ORACLE日期時間函數(shù)大全 TO_DATE格式(以時間:2007-11-02 13:45:25為例) Year: yy two digits 兩位年 顯示值:07 yyy three digits 三位年 顯示值:007 yyyy four digits 四位年 顯示值:2007 Month: mm number 兩位月 顯示值:11 mon abbreviated 字符集表示 顯示值:11月,若是英文版,顯示nov month spelled out 字符集表示 顯示值:11月,若是英文版,顯示november Day: dd number 當月第幾天 顯示值:02 ddd number 當年第幾天 顯示值:02 dy abbreviated 當周第幾天簡寫 顯示值:星期五,若是英文版,顯示fri day spelled out 當周第幾天全寫 顯示值:星期五,若是英文版,顯示friday ddspth spelled out, ordinal twelfth Hour: hh two digits 12小時進制 顯示值:01 hh24 two digits 24小時進制 顯示值:13 Minute: mi two digits 60進制 顯示值:45 Second: ss two digits 60進制 顯示值:25 其它 Q digit 季度 顯示值:4 WW digit 當年第幾周 顯示值:44 W digit 當月第幾周 顯示值:1 24小時格式下時間范圍為: 0:00:00 - 23:59:59.... 12小時格式下時間范圍為: 1:00:00 - 12:59:59 .... 1. 日期和字符轉(zhuǎn)換函數(shù)用法(to_date,to_char) select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual; //日期轉(zhuǎn)化為字符串 select to_char(sysdate,'yyyy') as nowYear from dual; //獲取時間的年 select to_char(sysdate,'mm')網(wǎng)站seo優(yōu)化 as nowMonth from dual; //獲取時間的月 select to_char(sysdate,'dd') as nowDay from dual; //獲取時間的日 select to_char(sysdate,'hh24') as nowHour from dual; //獲取時間的時 select to_char(sysdate,'mi') as nowMinute from dual; //獲取時間的分 select to_char(sysdate,'ss') as nowSecond from dual; //獲取時間的秒select to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss') from dual//2. select to_char( to_date(222,'J'),'Jsp') from dual 顯示Two Hundred Twenty-Two 3.求某天是星期幾 select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day') from dual; 星期一 select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual; monday 設(shè)置日期語言 ALTER SESSION SET NLS_DATE_LANGUAGE='AMERICAN'; 也可以這樣 TO_DATE ('2002-08-26', 'YYYY-mm-dd', 'NLS_DATE_LANGUAGE = A網(wǎng)站建設(shè)公司merican') 4. 兩個日期間的天數(shù) select floor(sysdate - to_date('20020405','yyyymmdd')) from dual; 5. 時間為null的用法 select id, active_date from table1 UNION select 1, TO_DATE(null) from dual; 注意要用TO_DATE(null) 6.月份差 a_date between to_date('20011201','yyyymmdd') and to_date('20011231','yyyymmdd') 那么12月31號中午12點之后和12月1號的12點之前是不包含在這個范圍之內(nèi)的。 所以,當時間需要精確的時候,覺得to_char還是必要的 7. 日期格式?jīng)_突問題 輸入的格式要看你安裝的ORACLE字符集的類型, 比如: US7ASCII, date格式的類型就是: '01-Jan-01' alter system set NLS_DATE_LANGUAGE = American alter session set NLS_DATE_LANGUAGE = American 或者在to_date中寫 select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual; 注意我這只是舉了NLS_DATE_LANGUAGE,當然還有很多, 可查看網(wǎng)seo優(yōu)化趨勢 select * from nls_session_parameters select * from V$NLS_PARAMETERS 8.聲明: 本文由我的SEOUC技術(shù)文章主頁發(fā)布于:2023-05-22 ,文章oracle常用函數(shù)匯總(分享)建站知識主要講述函數(shù),常用,oracle常用函數(shù)匯總(分享)建站知識1網(wǎng)站建設(shè)源碼以及服務器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請保留鏈接: http://www.bifwcx.com/article/web_5012.html