oracle中substr() instr() 用法

來源:互聯網
上載者:User

標籤:

--substr(字串,截取開始位置,截取長度)=返回截取的字select substr(‘miaoying‘,0,1) from dual;--返回結果為:mselect substr(‘miaoying‘,1,1) from dual;--返回結果為:m--說明0和1都表示截取的位置為第一個字元select substr(‘miaoying‘,-7,4) from dual;--返回結果為:iaoy--負數表示:-7表示從右邊開始數第七位開始,也就是i,截取長度為4的字串  --instr(源字串,目標字串,起始字串,匹配字串)=返回要截取的字串在源字串中的位置,從字元的開始,只檢索一次--instr(string1,string2,index1,index2) 表示:要在string1的index1號位置,開始尋找,第index2次,出現的string2select instr(‘miaoying‘,‘i‘,2,2) from dual;--返回6:也就是說:在"miaoying"的第2號位置開始,尋找第二次出現的i的位置select instr(‘miaoying‘,‘k‘,2,2)from dual;--返回0:即如果尋找不到,則返回0select instr(‘miaoying‘,‘i‘) from dual;--返回2select instr(‘miaoying‘,‘yi‘) from dual;--返回5:即"yi"的y的位置select instr(‘miaoying‘,‘i‘,-1,2) from dual;--返回2:--空格也是字元。。。。。select * from omgnode a where name like ‘%miaoying%‘select * from omgnode a where instr(name,‘miaoying‘)>0--效果一樣

 

oracle中substr() instr() 用法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.