oracle常用函數

來源:互聯網
上載者:User

標籤:acl   tca   集合   轉寄   cap   日期   floor   語句   oracle資料庫   

一、運算子
算術運算子:+ - * / 可以在select 語句中使用
串連運算子:|| select deptno|| dname from dept; 
比較子:> >= = != < <= like between is null in
邏輯運算子:not and or 
集合運算子: intersect ,union, union all, minus 
要求:對應集合的列數和資料類型相同
     查詢中不能包含long 列
     列的標籤是第一個集合的標籤
     使用order by時,必須使用位置序號,不能使用列名

二、時間相關
select to_char(to_date(‘2016-12-22‘,‘yyyy-mm-dd‘),‘day‘) from dual; --指定時間是周幾
select floor(sysdate - to_date(‘20020405‘,‘yyyymmdd‘)) from dual; --兩個日期間的天數
select TO_CHAR(SYSDATE,‘DDD‘),sysdate from dual; --一年的第多少天

--目前時間的時分秒(oracle資料庫時間哦)

三. 字元函數(可用於字面字元或資料庫列)

select instr(‘abcfdgfdhd‘,‘fd‘) from dual;--截取 4
select ‘HELLO‘||‘hello world‘ from dual;--拼接 HELLOhello world
select ltrim(‘ abc‘) s1,rtrim(‘zhang ‘) s2,trim(‘ zhang ‘) s3 from dual--;去掉空格
select trim(leading 9 from 9998767999) s1,trim(trailing 9 from 9998767999) s2,trim(9 from 9998767999) s3 from dual;--去掉前後墜
select ascii(‘a‘) from dual;--轉ascii
select chr(97) from dual;--擷取字母
select length(‘abcdef‘) from dual;--計算長度
select lower(‘ABC‘) s1,upper(‘def‘) s2, initcap(‘efg‘) s3 from dual; --initcap(首字母變大寫) ,lower(變小寫),upper(變大寫)
select translate(‘abc‘,‘b‘,‘xc‘) from dual; -- x是1位 結果是axc
select lpad(‘func‘,15,‘=‘) s1, rpad(‘func‘,15,‘-‘) s2 from dual;--lpad [左添充] rpad [右填充](用於控制輸出格式)
decode[實現if ..then 邏輯]
case[實現switch ..case 邏輯]

後面的有時間在完善 整理不易 轉寄請標明出處

oracle常用函數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.