Oracle文本函數簡介_oracle

來源:互聯網
上載者:User

Oracle文本函數使我們常用的函數,下面就為您介紹幾種Oracle文本函數的用法,供您參考學習,希望可以讓您對Oracle文本函數有更深的認識。

(1)UPPER、LOWER和INITCAP

這三個函數更改提供給它們的文體的大小寫。

select upper(product_name) from product;select lower(product_name) from product;select initcap(product_name) from product;

函數INITCAP能夠整理雜亂的文本,如下:

select initcap(‘this TEXT hAd UNpredictABLE caSE') from dual;


(2)LENGTH

求資料庫列中的資料所佔的長度。

select product_name,length(product_name) name_lengthfrom productorder by product_name;

(3)SUBSTR

取子串,格式為:

SUBSTR(源字串,起始位置,子串長度);

create table item_test(item_id char(20),item_desc char(25));insert into item_test values(‘LA-101','Can, Small');insert into item_test values(‘LA-102','Bottle, Small');insert into item_test values(‘LA-103','Bottle, Large');

取編號:

select substr(item_id,4,3) item_num,item_descfrom item_test;

(4)INSTR

確定子串在字串中的位置,格式如下:

INSTR(源字串,要尋找的字串,尋找起始位置)

select instr(‘this is line one','line',1) from dual;

其傳回值為子串在源字串中從起始位置開始第一次出現的位置。上面例子的傳回值為9。

select item_desc , instr(item_desc,',',1)from item_test;

(5)LTRIM、RTRIM和TRIM

去除字串左邊的空格、去除字串右邊的空格、去除字串左右兩邊的空格。

select ltrim(‘ abc def ‘) from dual;

以上就是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.