oracle的常用函數

來源:互聯網
上載者:User

標籤:

1. nvl

NVL函數的格式如下:NVL(expr1,expr2)

含義是:如果oracle第一個參數expr1為空白,那麼顯示第二個參數的值為expr2,如果第一個參數的值expr1不為空白,則顯示第一個參數本來的值。

2. nvl2

NVL2函數的格式如下:NVL2(expr1,expr2, expr3)

含義是:如果該函數的第一個參數expr1不為空白,那麼顯示第二個參數的值為expr2,如果第一個參數expr1的值為空白,則顯示第三個參數的值為expr3

3. 轉換函式

3.1  to_char()[將日期和數字類型轉換成字元類型]

日期轉換成字元類型:

select to_char(sysdate) s1,        to_char(sysdate,‘yyyy-mm-dd‘) s2,        to_char(sysdate,‘yyyy‘) s3,        to_char(sysdate,‘yyyy-mm-dd hh12:mi:ss‘) s4,        to_char(sysdate, ‘hh24:mi:ss‘) s5,        to_char(sysdate,‘DAY‘) s6    from dual;

數字轉換成字元類型:

select sal,to_char(sal,‘$99999‘) n1,to_char(sal,‘$99,999‘) n2 from emp

3.2  to_date()[將字元類型轉換為日期類型]

insert into emp(empno,hiredate) values(8000,to_date(‘2004-10-10‘,‘yyyy-mm-dd‘));

3.3  to_number() 轉換為數字類型

select to_number(to_char(sysdate,‘hh12‘)) from dual; //以數字顯示的小時數

4. 串連運算子||

select ‘hello‘||‘world‘ from dual

輸出結果是:helloworld

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.