oracle字串函數

來源:互聯網
上載者:User

標籤:

1. replace,translate

--translate 字元層級的替換--replace 字串層級的替換select replace(‘abaabbb‘,‘ab‘,‘c‘) from dual;--cacbbselect translate(‘aaabbb‘,‘ab‘,‘ce‘) from dual;--ccceee

 

2. concat 字串串連,等同於 || 

select concat(‘test‘, ‘_concat‘) from dual;--test_concatselect ‘test‘ || ‘_concat‘ from dual; --test_concat

 

3. upper,lower,initcap  指定語言集的方法:NLS_UPPER,NLS_LOWER,NLS_INITCAP

select upper(‘AaaaAa‘) from dual; --AAAAAAselect lower(‘AaaaAa‘) from dual; --aaaaaaselect initcap(‘aaaaa‘) from dual; --Aaaaaselect initcap(‘aaa aaa‘) from dual; --Aaa Aaa

 

4.lpad,rpad  字串填充,如果不指定填充字元,預設為空白格

select lpad(‘aa‘,10,‘0‘) from dual; --左填充  00000000aaselect rpad(‘aa‘,10,‘0‘) from dual; --右填充  aa00000000

 

5. ltrim,rtrim,trim(leading,trailing,both) 字串修剪,trim只支援單字元修剪? 預設剪去空格

select ltrim(‘111111111000123000‘,‘01‘) from dual; --從左截掉所有0和1 23000select rtrim(‘00012300011111‘,‘012‘) from dual;----從右截掉所有0和1 000123select trim(leading ‘0‘ from ‘000123000‘) from dual;  --從頭截掉所有的0 123000select trim(trailing ‘0‘ from ‘000123000‘) from dual;  --從尾截掉所有的0 000123select trim(both ‘0‘ from ‘000123000‘) from dual;  --兩邊同時截掉所有的0 123

 

6. substr

--substr(char,start,length) 截取char從start開始的長度為length的字串select substr(‘abc‘,0,1) from dual; --返回aselect substr(‘abc‘,1,1) from dual;--start為0和start為1效果相同select substr(‘abcdefgs‘,-5,3) from dual;--如果start為負數,則從倒數第start個字元開始截取  返回defselect substr(‘abcdefgs‘,-5) from dual;--如果省略length,則截取start直到結尾的字串  返回defgs

 

7. regexp_substr,regexp_replace

 

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.